Nikhil_Mcafee
14 years agoNew Contributor
email's are not getting sent. URGENT !!!!
Hi All
I am trying to send an email with an attachment using the script which in present in smartbear support artical, but the amils are not getting sent atall. The script executes successfully but no emails are getting sent.Please find the script below.
http://smartbear.com/support/viewarticle/9020/
Function SendEmail(mFrom, mTo, mSubject, mBody, mAttachment)
Dim smtpServer, portNumber, userName, userPassword
Dim useAutentification, useSSL, connectionTimeout
Dim schema, mConfig, mMessage
smtpServer = "smtp.gmail.com"
smtpPort = 465
userLogin = "XYZ@gmail.com" ' e.g. abc@gmail.com
userPassword = "Password"
autentificationType = 1 ' cdoBasic
connectionTimeout = 30
' Required by GMail
useSSL = True
Err.Clear()
On Error Resume Next
schema = "http://schemas.microsoft.com/cdo/configuration/"
Set mConfig = Sys.OleObject("CDO.Configuration")
mConfig.Fields.Item(schema & "sendusing") = 2 ' cdoSendUsingPort
mConfig.Fields.Item(schema & "smtpserver") = smtpServer
mConfig.Fields.Item(schema & "smtpserverport") = smtpPort
mConfig.Fields.Item(schema & "sendusername") = userLogin
mConfig.Fields.Item(schema & "sendpassword") = userPassword
mConfig.Fields.Item(schema & "smtpauthenticate") = autentificationType
mConfig.Fields.Item(schema & "smtpusessl") = useSSL
mConfig.Fields.Item(schema & "smtpconnectiontimeout") = connectionTimeout
mConfig.Fields.Update()
Set mMessage = Sys.OleObject("CDO.Message")
Set mMessage.Configuration = mConfig
mMessage.From = mFrom
mMessage.To = mTo
mMessage.Subject = mSubject
mMessage.HTMLBody = mBody
If 0 < Len(mAttachment) Then
mMessage.AddAttachment(mAttachment)
End If
mMessage.Send()
If Err.Number > 0 Then
Call Log.Error("E-mail cannot be sent", Err.Description)
SendEMail = False
Err.Clear()
Else
Log.Message("Message to <" & mTo & "> was successfully sent")
SendEMail = True
End If
End Function
With Regards
Nikhil C. Indurkar