Vbscript build error when running bat file to send email

Asked

Viewed 116 times

1

The error is described in the image. Can anyone tell me why? I have tried to save the file with encoded ANSI but still does not give.

 Set objMail = CreateObject("CDO.Message")
    Set objConf = CreateObject("CDO.Configuration")
    Set objFlds = objConf.Fields
    objFlds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'cdoSendUsingPort
    objFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.your-site-url.com" 'your smtp server domain or IP address goes here
    objFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'default port for email
    'uncomment next three lines if you need to use SMTP Authorization
    'objFlds.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "your-username"
    'objFlds.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "your-password"
    'objFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'cdoBasic
    objFlds.Update
    objMail.Configuration = objConf
    objMail.FromName = "Your Name"
    objMail.From = "[email protected]"
    objMail.To = "[email protected]"
    objMail.Subject = "Email Subject Text"
    objMail.TextBody = "The message of the email..."
    objMail.Send
    Set objFlds = Nothing
    Set objConf = Nothing
    Set objMail = Nothing

inserir a descrição da imagem aqui

  • which editor you’re using?

  • It is already solved. Just remove line 12 that will not be needed once the box is already set to the correct Name.

  • You can post a reply explaining how it was resolved or simply edit your question so that other users understand.

  • Already this, now you can vote to demonstrate the resolution pf

1 answer

1

Solution:

Set objMail = CreateObject("CDO.Message")
    Set objConf = CreateObject("CDO.Configuration")
    Set objFlds = objConf.Fields
    objFlds.Item("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2 'cdoSendUsingPort
    objFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.your-site-url.com" 'your smtp server domain or IP address goes here
    objFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 25 'default port for email
    'uncomment next three lines if you need to use SMTP Authorization
    'objFlds.Item("http://schemas.microsoft.com/cdo/configuration/sendusername") = "your-username"
    'objFlds.Item("http://schemas.microsoft.com/cdo/configuration/sendpassword") = "your-password"
    'objFlds.Item("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1 'cdoBasic
    objFlds.Update
    objMail.Configuration = objConf
    objMail.From = "[email protected]"
    objMail.To = "[email protected]"
    objMail.Subject = "Email Subject Text"
    objMail.TextBody = "The message of the email..."
    objMail.Send
    Set objFlds = Nothing
    Set objConf = Nothing
    Set objMail = Nothing



Store the file with encoding ANSI and extent .vbs and will already work perfectly. In addition we will have to give permission in the mailbox to send email by smtp.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.