Using Access 2010/Windows 7.
I found this code somewhere and I made the changes necessary. (email addresses, password)
When I run it I get the error: The transport failed to connect to the server.
Setting the port to 587 doesn't solve it either.
Any idea what I'm missing?
I found this code somewhere and I made the changes necessary. (email addresses, password)
When I run it I get the error: The transport failed to connect to the server.
Setting the port to 587 doesn't solve it either.
Any idea what I'm missing?
Code:
Dim iMsg As Object
Dim iConf As Object
Dim strbody As String
Dim Flds As Variant
Set iMsg = CreateObject("CDO.Message")
Set iConf = CreateObject("CDO.Configuration")
iConf.Load -1 ' CDO Source Defaults
Set Flds = iConf.Fields
With Flds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'NTLM method
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/smptserverport") = 465
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = 60
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "frommyemail@gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "mypassword"
.Update
End With
strbody = "Hi there" & vbNewLine & vbNewLine & _
"This is line 1" & vbNewLine & _
"This is line 2" & vbNewLine & _
"This is line 3" & vbNewLine & _
"This is line 4"
With iMsg
Set .Configuration = iConf
.To = "tomyemail@gmail.com"
.CC = ""
.BCC = ""
.From = "frommyemail@gmail.com>"
.Subject = "New figures"
.TextBody = strbody
.Send
End With