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

Spell Check in Excel
Press F7 to start spell check in Excel. Be careful, by default, Excel does not check Capitalized Werds (whoops)

Forum statistics

Threads
1,223,904
Messages
6,175,295
Members
452,633
Latest member
DougMo

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