VBScript compile error when executing bat file for email sending

1

The error is described in the image. Can someone tell me the reason? I've tried to save the file with encoded ANSI but it 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

    
asked by anonymous 27.10.2016 / 10:58

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



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

    
27.10.2016 / 12:36