Link to home
Start Free TrialLog in
Avatar of Sudhir sharma
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.Configuration")
    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.com"
        .CC = "v_2sudhs@hotmail.com"
        .BCC = "sudhirdutt.sharma@orange.com"
        .From = "sudhirdutt.sharma#gmail.com"
        .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
Avatar of als315
als315
Flag of Russian Federation image

You can't use gmail server without authorization. Add user and password.
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
Avatar of Sudhir sharma
Sudhir sharma

ASKER

Thank you!!  I  shall try these steps and correction .. shall  get back to you in a days time.
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.Configuration")
    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.com"
        .Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "*******"
        .Update
    End With
   
    strBody = "mail text details"
   
    With iMSG
        .To = "sharma.sudhirdutt@gmail.com"
        .CC = "v_2sudhs@hotmail.com"
        .BCC = "sudhirdutt.sharma@orange.com"
        .From = "sudhirdutt.sharma@gmail.com"
        .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
Avatar of als315
als315
Flag of Russian Federation image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
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
sorry missed to share the code

Dim myMail As CDO.Message


Set myMail = New CDO.Message


myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = True
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/STARTTLS") = True

myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smptauthenticate") = 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/sendpassword") = "Haiwahi09!"

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
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
You have one syntax error:
myMail.Configuration.Fields.Item("http://schemas.microsoft.com/cdo/configuration/smptauthenticate") = 1
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

Open in new window

Finally !!!! it worked .... Thank you !!! Thank you!!! sooo Much ALS .. . you are a Star!!!!
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)
no worries !! Still Thank you!! for helping resolve the issue.