Question
Thread display: Collapse - |
All Answers
Share your knowledge
Start or search
Create a new discussion
If you're asking for technical help, please be sure to include all your system info, including operating system, model number, and any other specifics related to the problem. Also please exercise your best judgment when posting in the forums--revealing personal information such as your e-mail address, telephone number, and address is not recommended.
error while sending mails using CDO.Message object
I am trying to send mails from my excel using VBA and CDO.Message and CDO.Configuration Object
See the below code
------------------------------
Function SendMailTo(sTo, sSubject, sBody)
Dim oMsg As Object
Dim oConf As Object
Dim Flds As Object
Dim strSch As String
Const cdoBasic = 1
Set oMsg = CreateObject("CDO.Message")
Set oConf = CreateObject("CDO.Configuration")
oConf.Load -1 ' CDO Source Defaults
Set Flds = oConf.Fields
strSch = "http://schemas.microsoft.com/cdo/configuration/"
With Flds
.Item(strSch & "sendusing") = 2
.Item(strSch & "smtpauthenticate") = cdoBasic
.Item(strSch & "smtpserver") = "smtp.gmail.com"
.Item(strSch & "sendusername") = "srinivas.2447.p@gmail.com"
.Item(strSch & "sendpassword") = "****" 'my password is given
.Item(strSch & "smtpserverport") = 465
.Item(strSch & "smtpusessl") = True
.Update
End With
With oMsg
Set .Configuration = oConf
.To = sTo
.CC = ""
.Bcc = ""
.From = """Srinivas P"" <srinivas.2447.p@gmail.com>"
.Subject = sSubject
.TextBody = sBody
.Send
End With
Set oMsg = Nothing
Set oConf = Nothing
End Function
now when i call this function it says .
"Transport failed to connect to the server" i dont want to use any outlook kind of a thing.
Any solutions would be appreciated.
Thanks in advance,
Srinivas P.