• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

Auto Email using Gmail

GeraldDLT

Member
Hello,

Need to create auto email using gmail with data inputs from excel.
Whenever i try simple email, i'm getting this error.

"The transport failed to connect the server."
upload_2018-3-18_16-57-52-png.50831

Source: https://www.makeuseof.com/tag/send-emails-excel-vba/

Any advise?


Thanks,
Gerald
 
Hi,

If you receive an error that reads The transport failed to connect to the server, make sure you’ve entered the correct username, password, SMTP server, and port number in the lines of code listed underneath With SMTP_Config
 
Thanks, Deepak.

Can you look into this?

Code:
Sub test()
Dim CDO_Mail As Object
Dim CDO_Config As Object
Dim SMTP_Config As Variant
Dim strSubject As String
Dim strFrom As String
Dim strTo As String
Dim strCc As String
Dim strBcc As String
Dim strBody As String

strSubject = "Results from Excel Spreadsheet"
strFrom = "TEST@gmail.com"
strTo = "TEST@gmail.com"
strCc = ""
strBcc = ""
strBody = "The total results for this quarter are: "


Set CDO_Mail = CreateObject("CDO.Message")
On Error GoTo Error_Handling

Set CDO_Config = CreateObject("CDO.Configuration")
CDO_Config.Load -1

Set SMTP_Config = CDO_Config.Fields

With SMTP_Config
 .Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
 .Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
 .Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "TEST@gmail.com"
 .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "******"
 .Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25
 .Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
 .Update
End With

With CDO_Mail
 Set .Configuration = CDO_Config
End With

CDO_Mail.Subject = strSubject
CDO_Mail.From = strFrom
CDO_Mail.To = strTo
CDO_Mail.TextBody = strBody
'CDO_Mail.CC = strCc
'CDO_Mail.BCC = strBcc
CDO_Mail.Send

Error_Handling:
If Err.Description <> "" Then MsgBox Err.Description

End Sub
 
Thanks, Belleke.

Tried changing serverport to 465, still getting the err msg.
I'm also sure i input the password correctly.
 
Back
Top