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>
Please find the VBA code i am using to send mail.Getting error
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: