1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49
|
Public Function SendEmail(ByRef pSubject As String, ByRef pBody As String, ByRef pEmail As String) As String
Dim errmsg As String
Dim mailer As Object
Dim myI As Object
Dim myEmailArray As Object
errmsg = ""
On Error Resume Next
'mailer = CreateObject("SMTPsvg.Mailer")
'BB Team: I Have added this line below to replace the line up,
mailer = CType(Activator.CreateInstance("SMTPsvg", "SMTPsvg.Mailer").Unwrap(), SMTPsvg.Mailer)
If CDbl(Err.Number & " " & Err.Source) <> 0 Then
errmsg = "Error creating ASPMailer object: " & " Line=" & Erl() & " Description=" & Err.Description
Else
mailer.FromAddress = cSenderAddress
mailer.FromName = cSenderName
mailer.RemoteHost = cMailHosts
If InStr(1, pEmail, ",") > 0 Then
myEmailArray = Split(pEmail, ",")
For myI = LBound(myEmailArray) To UBound(myEmailArray)
mailer.Addrecipient(myEmailArray(myI), myEmailArray(myI))
Next
Else
mailer.Addrecipient(pEmail, pEmail)
End If
mailer.subject = pSubject
mailer.bodytext = "<html><body><font face=""verdana,arial,helvetica"" size=""2"">" & Replace(pBody, vbCrLf, "<br>") & "</font></body></html>"
mailer.Timeout = cMailTimeout
' use ISO character set - is better for special characters
mailer.Charset = 2
' we use html mails
mailer.ContentType = "text/html"
'priority: 1 is high, 3 is normal, 5 is low
mailer.priority = 3
mailer.Urgent = False
If Not mailer.SendMail Then
errmsg = "Error sending E-Mail to <" & pEmail & "> using hosts <" & cMailHosts & "> (" & mailer.Response & ")"
End If
mailer = Nothing
End If
If Len(errmsg) > 0 Then
DebugPrint(errmsg)
TracePrint(errmsg)
End If
SendEmail = errmsg
End Function |
Partager