Sub Class_Globals
Private SMTP As SMTP
End Sub
'Initializes the object. You can add parameters to this method if needed.
Public Sub Initialize
Dim mailServer, mailServerPort, mailServerUserName, mailServerPassword, security, mailSender As String
Try
mailSender = Main.settings.Get("MailSender")
mailServer = Main.settings.Get("MailServer")
mailServerPort = Main.settings.Get("MailServerPort")
mailServerUserName = Main.settings.Get("MailServerUserName")
mailServerPassword = Main.settings.Get("MailServerPassword")
security = Main.settings.Get("Security")
SMTP.Initialize(mailServer, mailServerPort, mailServerUserName, mailServerPassword, "SMTP")
SMTP.Sender = mailSender
' Select Main.settings.Get("AuthMethod")
' Case "AUTH_PLAIN"
' SMTP.AuthMethod = SMTP.AUTH_PLAIN
' Case "AUTH_LOGIN"
' SMTP.AuthMethod = SMTP.AUTH_LOGIN
' Case "AUTH_CRAM_MD5"
' SMTP.AuthMethod = SMTP.AUTH_CRAM_MD5
' Case Else
' SMTP.AuthMethod = SMTP.AUTH_PLAIN
' End Select
'
' Select security.ToUpperCase
' Case "SSL"
' SMTP.UseSSL = True
' SMTP.StartTLSMode = False
' Case "TLS"
' SMTP.StartTLSMode = True
' SMTP.UseSSL = False
' Case Else
' SMTP.UseSSL = False
' SMTP.StartTLSMode = False
' End Select
Log("mailSender: " & mailSender)
Log("mailServerPort: " & mailServerPort)
Log("mailServerUserName: " & mailServerUserName)
Log("mailServerPassword: " & mailServerPassword)
Log("UseSSL: " & SMTP.UseSSL)
Log("StartTLSMode: " & SMTP.StartTLSMode)
Catch
Log("SendMail Initialize")
Log(LastException)
End Try
End Sub
public Sub sendMessage(recipients As List, subject As String, cc As List, bcc As List, body As String, htmlBody As Boolean)
Try
SMTP.Body = body
SMTP.HtmlBody = htmlBody
SMTP.To = recipients
If cc.Size > 0 Then SMTP.CC = cc
If bcc.Size > 0 Then SMTP.BCC = bcc
SMTP.Subject = subject
' Log(SMTP.To)
' Log(SMTP.CC)
' Log(SMTP.BCC)
' Log(SMTP.HtmlBody)
' Log(SMTP.Body)
SMTP.Send
Catch
' Log("sendMessage")
Log("SendMail sendMessage")
Log(LastException)
End Try
End Sub
Private Sub SMTP_MessageSent(Success As Boolean)
Try
' Log(Success)
If Not(Success) Then
Log("SendMail MessageSent Failure")
Log(LastException.Message)
End If
Catch
' Log("EventName_MessageSent")
Log("SendMail MessageSent Error")
Log(LastException)
End Try
End Sub