Gmail Smtp mail

gokulu

New Member
Joined
Dec 7, 2017
Messages
9
Hi,

Please find the VBA code i am using to send mail.Getting error
.(Run time Error '-2147220975(80040211)' : The message could not be sent to the SMTP server. The transport error code was 0x80040217. The server response was not available)


Tried to disable two step verification and enable less secure Apps in security,Its not working,, Any help

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/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "My mail ID"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Mail Password"
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
.Update
End With


strbody = "Dear Sir/Madam," & vbNewLine & vbNewLine & _
"Please find your Salary Slip for the month of" & Worksheets("Staff_payslip").Range("D37").Value & vbNewLine & _
" " & vbNewLine & _
"--" & vbNewLine & _
"Regards," & vbNewLine & _
"Team - HR"


With iMsg
Set .Configuration = iConf
.To = Worksheets("Staffs").Range("F" & x).Value
.CC = ""
.BCC = ""
' Note: The reply address is not working if you use this Gmail example
' It will use your Gmail address automatic. But you can add this line
' to change the reply address .ReplyTo = "Reply@something.nl"
.From = """RICCO-HR"" <my mail="" id="">"
.Subject = "Salary Slip of " & Worksheets("Staffs").Range("C" & x).Value & " for " & Worksheets("Staff_payslip").Range("D37").Value
.TextBody = strbody
.AddAttachment strPath & Worksheets("Staffs").Range("C" & x).Value & ".pdf"
.Send
End With</my>
 
Last edited:

Excel Facts

Format cells as time
Select range and press Ctrl+Shift+2 to format cells as time. (Shift 2 is the @ sign).

Forum statistics

Threads
1,216,604
Messages
6,131,704
Members
449,666
Latest member
Tommy2Tables365

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top