anandan.cr@gmail.com
Member
- Local time
- Today, 08:22
- Joined
- Oct 7, 2016
- Messages
- 43
Dear Sir,
The Below mentioned VBA Access Code is working in Windows 11 O/s but the same is not working in Windows 7 O/S.
Similarly respective setting of Email Accounts of different Operating System i.e Windows 11 O/s & Windows 7 O/s is attached here as Image.
Unable to send the Email , We are getting an Run-time error '-2147220973 (80040213)''
"The Transport failed to connect to server."
I tried to change the SMTP setting from 465 to 587 , but it is not working.
Please suggest the VBA code to change the SSL Setting.
or
Please correct the code to send email.
Sub SendMail()
Dim objEmail
Dim objMail As Object
Const cdoSendUsingPort = 2 ' Send the message using SMTP
Const cdoBasicAuth = 1 ' Clear-text authentication
Const cdoTimeout = 60 ' Timeout for SMTP in seconds
mailServer = "ambassadorindia.icewarpcloud.in"
SMTPport = 465
mailusername = "ABC@ambassadorindia.com"
mailpassword = "******"
mailto = "anandan.cr@gmail.com"
mailSubject = "test : " & Now()
mailBody = "Dear Sir/Madam," & vbCrLf & _
"" & vbCrLf & _
" Please find attached Salary Slip " & vbCrLf & _
" For the month of " & vbCrLf & _
" " & vbCrLf & _
" Regards" & vbCrLf & _
" " & vbCrLf & _
" HR Department" & vbCrLf & _
" " & vbCrLf & _
" " & vbCrLf & _
" Company Name" & vbCrLf & _
" This Salary Slip is password protected.The password is 8-character password - combination of the first four letters of your name in CAPITAL( as it is mentioned in your Personal File kept in HR) and the date and month of your Date of Birth(DOB) ( as updated in our records) " & vbCrLf & _
" " & vbCrLf & _
" For instance, " & vbCrLf & _
" If your name is C.R.Anandan and your DOB(DD-MMM-YYYY) is 01-FEB-1991 then the password would be C.R.0102 " & vbCrLf & _
" If your name is CRAnandan and your DOB(DD-MMM-YYYY) is 01-FEB-1991 then the password would be CRAN0102 " & vbCrLf & _
" " & vbCrLf
Set objEmail = CreateObject("CDO.Message")
Set objConf = objEmail.Configuration
Set objFlds = objConf.Fields
With objFlds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = mailServer
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPport
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = cdoTimeout
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasicAuth
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = mailusername
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = mailpassword
.Update
End With
objEmail.To = mailto
objEmail.From = mailusername
objEmail.Subject = mailSubject
objEmail.TextBody = mailBody
objEmail.AddAttachment "d:\Report.pdf"
objEmail.Send
Set objFlds = Nothing
Set objConf = Nothing
Set objEmail = Nothing
End Sub
The Below mentioned VBA Access Code is working in Windows 11 O/s but the same is not working in Windows 7 O/S.
Similarly respective setting of Email Accounts of different Operating System i.e Windows 11 O/s & Windows 7 O/s is attached here as Image.
Unable to send the Email , We are getting an Run-time error '-2147220973 (80040213)''
"The Transport failed to connect to server."
I tried to change the SMTP setting from 465 to 587 , but it is not working.
Please suggest the VBA code to change the SSL Setting.
or
Please correct the code to send email.
Sub SendMail()
Dim objEmail
Dim objMail As Object
Const cdoSendUsingPort = 2 ' Send the message using SMTP
Const cdoBasicAuth = 1 ' Clear-text authentication
Const cdoTimeout = 60 ' Timeout for SMTP in seconds
mailServer = "ambassadorindia.icewarpcloud.in"
SMTPport = 465
mailusername = "ABC@ambassadorindia.com"
mailpassword = "******"
mailto = "anandan.cr@gmail.com"
mailSubject = "test : " & Now()
mailBody = "Dear Sir/Madam," & vbCrLf & _
"" & vbCrLf & _
" Please find attached Salary Slip " & vbCrLf & _
" For the month of " & vbCrLf & _
" " & vbCrLf & _
" Regards" & vbCrLf & _
" " & vbCrLf & _
" HR Department" & vbCrLf & _
" " & vbCrLf & _
" " & vbCrLf & _
" Company Name" & vbCrLf & _
" This Salary Slip is password protected.The password is 8-character password - combination of the first four letters of your name in CAPITAL( as it is mentioned in your Personal File kept in HR) and the date and month of your Date of Birth(DOB) ( as updated in our records) " & vbCrLf & _
" " & vbCrLf & _
" For instance, " & vbCrLf & _
" If your name is C.R.Anandan and your DOB(DD-MMM-YYYY) is 01-FEB-1991 then the password would be C.R.0102 " & vbCrLf & _
" If your name is CRAnandan and your DOB(DD-MMM-YYYY) is 01-FEB-1991 then the password would be CRAN0102 " & vbCrLf & _
" " & vbCrLf
Set objEmail = CreateObject("CDO.Message")
Set objConf = objEmail.Configuration
Set objFlds = objConf.Fields
With objFlds
.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = cdoSendUsingPort
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = mailServer
.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = SMTPport
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/smtpconnectiontimeout") = cdoTimeout
.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = cdoBasicAuth
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = mailusername
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = mailpassword
.Update
End With
objEmail.To = mailto
objEmail.From = mailusername
objEmail.Subject = mailSubject
objEmail.TextBody = mailBody
objEmail.AddAttachment "d:\Report.pdf"
objEmail.Send
Set objFlds = Nothing
Set objConf = Nothing
Set objEmail = Nothing
End Sub