Hi Ann,
As per the example, I modified the code as below, it says email is sent successfully but I dont see any email in the inbox nor in sent items :(
Where am I going wrong?
Sub Test()
Test()
Call SendEmail("anil.yadrami@in4velocity.com", "anil.yadrami@in4velocity.com", "Test", "TestMessage", "")
End Sub
Function SendEmail(mFrom, mTo, mSubject, mBody, mAttachment)
SendEmail(mFrom, mTo, mSubject, mBody, mAttachment)
Dim smtpServer, portNumber, userName, userPassword
Dim useAutentification, useSSL, connectionTimeout
Dim schema, mConfig, mMessage
smtpServer = "smtp.gmail.com"
smtpPort = 587
userLogin = "anil.yadrami@in4velocity.com" ' e.g. abc@gmail.com
userPassword = "Pwd123456"
autentificationType = 1 ' cdoBasic
connectionTimeout = 30
' Required by GMail
useSSL = True
Err.Clear()
On Error Resume Next
schema = https://www.google.com/a/in4velocity.com/
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("E:\Anil-Backup\Test Complete\Projects_Old\In4Suite Project\TC_Command_Line.txt") Then
mMessage.AddAttachment("E:\Anil-Backup\Test Complete\Projects_Old\In4Suite Project\TC_Command_Line.txt")
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