Email sending via script is not working
i am trying to send email through scripts but it is not working. do we need any dll for the same ? i am getting error code in EnvelopeFields : "The requested property or feature, while supported, is not available at this time or in this context."
please correct me if am missing any steps .
i am using below code ..
function
Test()
Call SendEmail("EMAIL from", "EMAIL to", "Test", "TestMessage", "")
End
function
Function
SendEmail(mFrom, mTo, mSubject, mBody, mAttachment)
On
Error Resume Next
Dim smtpServer, smtpPort, userLogin, userPassword
Dim authenticationType, useSSL, connectionTimeout
Dim schema, mConfig, mMessage
smtpServer = "" ' provided required smtpserver.
smtpPort = 587
userLogin = "anita.desai"
' e.g. "abc" if the address is abc@gmail.com
userPassword = "Tieto5890"
authenticationType = 1
' cdoBasic
' connectionTimeout = 30
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") = authenticationType
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