Sudhir sharma
asked on
Error 2147220960, SendUsing configuration invalid. error received while trying to send email
Need Help!!
Error 2147220960, SendUsing configuration invalid. error received while trying to send email using below code: (I am on Excel 2010
On Error GoTo HandleError
Dim iMSG As Object
Dim iCONF As Object
Dim strBody As String
Dim FLDS As Variant
Set iMSG = CreateObject("CDO.Message" )
Set iCONF = CreateObject("CDO.Configur ation")
iCONF.Load -1
Set FLDS = iCONF.Fields
With FLDS
.Item("http://schema/cdo/configuration/sendusing") = 2
.Item("http://schemas/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("https://schema/cdo/configuration/smtpserverport") = 587
.Update
End With
strBody = "mail text deetails"
With iMSG
.To = "sharma.sudhirdutt@gmail.c om"
.CC = "v_2sudhs@hotmail.com"
.BCC = "sudhirdutt.sharma@orange. com"
.From = "sudhirdutt.sharma#gmail.c om"
.Subject = "Test mail from Excel"
.TextBody = "strBody"
.Send
End With
MsgBox "Mail sent"
HandleError:
If Err.Number <> 0 Then
MsgBox "We encountered " & Err.Number & " " & Err.Description
Exit Sub
End If
Error 2147220960, SendUsing configuration invalid. error received while trying to send email using below code: (I am on Excel 2010
On Error GoTo HandleError
Dim iMSG As Object
Dim iCONF As Object
Dim strBody As String
Dim FLDS As Variant
Set iMSG = CreateObject("CDO.Message"
Set iCONF = CreateObject("CDO.Configur
iCONF.Load -1
Set FLDS = iCONF.Fields
With FLDS
.Item("http://schema/cdo/configuration/sendusing") = 2
.Item("http://schemas/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("https://schema/cdo/configuration/smtpserverport") = 587
.Update
End With
strBody = "mail text deetails"
With iMSG
.To = "sharma.sudhirdutt@gmail.c
.CC = "v_2sudhs@hotmail.com"
.BCC = "sudhirdutt.sharma@orange.
.From = "sudhirdutt.sharma#gmail.c
.Subject = "Test mail from Excel"
.TextBody = "strBody"
.Send
End With
MsgBox "Mail sent"
HandleError:
If Err.Number <> 0 Then
MsgBox "We encountered " & Err.Number & " " & Err.Description
Exit Sub
End If
ASKER
Thank you!! I shall try these steps and correction .. shall get back to you in a days time.
ASKER
Hi
I updaed code as below : however still ssame error, seems like some thing I am missing here :
On Error GoTo HandleError
Dim iMSG As Object
Dim iCONF As Object
Dim strBody As String
Dim FLDS As Variant
Set iMSG = CreateObject("CDO.Message" )
Set iCONF = CreateObject("CDO.Configur ation")
iCONF.Load -1
Set FLDS = iCONF.Fields
With FLDS
.Item("http://schema/cdo/configuration/sendusing") = 2
.Item("http://schemas/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("https://schema/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "sharma.sudhirdutt@gmail.c om"
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "*******"
.Update
End With
strBody = "mail text details"
With iMSG
.To = "sharma.sudhirdutt@gmail.c om"
.CC = "v_2sudhs@hotmail.com"
.BCC = "sudhirdutt.sharma@orange. com"
.From = "sudhirdutt.sharma@gmail.c om"
.Subject = "Test mail from Excel"
.TextBody = "strBody"
.Send
End With
MsgBox "Mail sent"
HandleError:
If Err.Number <> 0 Then
MsgBox "We encountered " & Err.Number & " " & Err.Description
Exit Sub
End If
End Sub
I updaed code as below : however still ssame error, seems like some thing I am missing here :
On Error GoTo HandleError
Dim iMSG As Object
Dim iCONF As Object
Dim strBody As String
Dim FLDS As Variant
Set iMSG = CreateObject("CDO.Message"
Set iCONF = CreateObject("CDO.Configur
iCONF.Load -1
Set FLDS = iCONF.Fields
With FLDS
.Item("http://schema/cdo/configuration/sendusing") = 2
.Item("http://schemas/cdo/configuration/smtpserver") = "smtp.gmail.com"
.Item("https://schema/cdo/configuration/smtpserverport") = 25
.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "sharma.sudhirdutt@gmail.c
.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "*******"
.Update
End With
strBody = "mail text details"
With iMSG
.To = "sharma.sudhirdutt@gmail.c
.CC = "v_2sudhs@hotmail.com"
.BCC = "sudhirdutt.sharma@orange.
.From = "sudhirdutt.sharma@gmail.c
.Subject = "Test mail from Excel"
.TextBody = "strBody"
.Send
End With
MsgBox "Mail sent"
HandleError:
If Err.Number <> 0 Then
MsgBox "We encountered " & Err.Number & " " & Err.Description
Exit Sub
End If
End Sub
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello als
I checked the gmail recommendations and made one correction change the server port to 465 as I am using smtp.gmail.com, however issue is still there.
regards
Sudhir
I checked the gmail recommendations and made one correction change the server port to 465 as I am using smtp.gmail.com, however issue is still there.
regards
Sudhir
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Hello Als
Used the advice able to move one step , able to connect however now server is rejecting my sender email address :
-2147220978The server rejected the sender address. The server response was: 530 5.5.1 https://support.google.com/mail/?p=WantAuthError c53sm12474199wra.16 - gsmtp
Used the advice able to move one step , able to connect however now server is rejecting my sender email address :
-2147220978The server rejected the sender address. The server response was: 530 5.5.1 https://support.google.com/mail/?p=WantAuthError c53sm12474199wra.16 - gsmtp
ASKER
sorry missed to share the code
Dim myMail As CDO.Message
Set myMail = New CDO.Message
myMail.Configuration.Field s.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
myMail.Configuration.Field s.Item("http://schemas.microsoft.com/cdo/configuration/STARTTLS") = True
myMail.Configuration.Field s.Item("http://schemas.microsoft.com/cdo/configuration/smptauthenticate") = 1
myMail.Configuration.Field s.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
myMail.Configuration.Field s.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
myMail.Configuration.Field s.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
myMail.Configuration.Field s.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "sharma.sudhirdutt@gmail.c om"
myMail.Configuration.Field s.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "Haiwahi09!"
myMail.Configuration.Field s.Update
With myMail
.Subject = "Test Email from Sudhir"
.From = "sharma.sudhirdut@gmail.co m"
.To = "sharma.sudhirdutt@gmail.c om; sudhirdutt.sharma@orange.c om"
'.CC = "v_2sudhs@hotmail.com"
'.BCC = ""
.TextBody = "Chal gaya!"
'.AddAttachment "C:\Users\takyar\Desktop\e mail-via-g mail.txt"
End With
On Error GoTo error_handle
myMail.Send
'MsgBox("Mail has been sent")
error_handle:
MsgBox Err.Number & "" & Err.Description
Sheet1.Range("B2") = Err.Number & "" & Err.Description
Exit Sub
Set myMail = Nothing
Dim myMail As CDO.Message
Set myMail = New CDO.Message
myMail.Configuration.Field
myMail.Configuration.Field
myMail.Configuration.Field
myMail.Configuration.Field
myMail.Configuration.Field
myMail.Configuration.Field
myMail.Configuration.Field
myMail.Configuration.Field
myMail.Configuration.Field
With myMail
.Subject = "Test Email from Sudhir"
.From = "sharma.sudhirdut@gmail.co
.To = "sharma.sudhirdutt@gmail.c
'.CC = "v_2sudhs@hotmail.com"
'.BCC = ""
.TextBody = "Chal gaya!"
'.AddAttachment "C:\Users\takyar\Desktop\e
End With
On Error GoTo error_handle
myMail.Send
'MsgBox("Mail has been sent")
error_handle:
MsgBox Err.Number & "" & Err.Description
Sheet1.Range("B2") = Err.Number & "" & Err.Description
Exit Sub
Set myMail = Nothing
ASKER
and if Use port as 25 I get similar err:
-2147220978The server rejected the sender address. The server response was: 530 5.5.1 https://support.google.com/mail/?p=WantAuthError v126sm3096213wmd.11 - gsmtp
-2147220978The server rejected the sender address. The server response was: 530 5.5.1 https://support.google.com/mail/?p=WantAuthError v126sm3096213wmd.11 - gsmtp
You have one syntax error:
myMail.Configuration.Field s.Item("http://schemas.microsoft.com/cdo/configuration/smptauthenticate") = 1
smtpauthenticate
myMail.Configuration.Field
smtpauthenticate
Dim myMail As CDO.Message
Set myMail = New CDO.Message
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = 1
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "sharma.sudhirdutt@gmail.com"
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpaccountname") = "sharma.sudhirdutt@gmail.com"
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "YourPassword"
myMail.Configuration.Fields.Update
With myMail
.Subject = "Test Email from Sudhir"
.From = "sharma.sudhirdut@gmail.com"
.To = "sharma.sudhirdutt@gmail.com; sudhirdutt.sharma@orange.com"
'.CC = "v_2sudhs@hotmail.com"
'.BCC = ""
.TextBody = "Chal gaya!"
'.AddAttachment "C:\Users\takyar\Desktop\email-via-gmail.txt"
End With
On Error GoTo error_handle
myMail.Send
'MsgBox ("Mail has been sent")
error_handle:
MsgBox Err.Number & "" & Err.Description
Sheet1.Range("B2") = Err.Number & "" & Err.Description
Exit Sub
Set myMail = Nothing
ASKER
Finally !!!! it worked .... Thank you !!! Thank you!!! sooo Much ALS .. . you are a Star!!!!
ASKER
Finally my issue is resolved, I used the advice and steps provided by als315 specially referring t link and TLS settings for GMAIL. Before this I had referred number of sites on internet to find the out .. but nothing worked . Thank you!! als315
It was my error. CDO can't be used with TLS encryption, only with SSL (smtpusessl)
ASKER
no worries !! Still Thank you!! for helping resolve the issue.
Field "from" also should be correct (replace # with @
Look at details here:
https://www.experts-exchange.com/questions/21277383/runtime-error-2147220960-80040220-The-SendUsing-configuration-is-invalid.html