VBScript to send email without running Outlook

后端 未结 2 1151
抹茶落季
抹茶落季 2020-11-30 08:44

I have written an automated test that runs each night, and I would like to email the results each night once the test is finished.

In order to do this I attempted to

相关标签:
2条回答
  • 2020-11-30 09:24

    Yes. Blat or any other self contained SMTP mailer. Blat is a fairly full featured SMTP client that runs from command line

    Blat is here

    0 讨论(0)
  • 2020-11-30 09:36

    You can send email without Outlook in VBScript using the CDO.Message object. You will need to know the address of your SMTP server to use this:

    Set MyEmail=CreateObject("CDO.Message")
    
    MyEmail.Subject="Subject"
    MyEmail.From="name@domain.com"
    MyEmail.To="a@a.com"
    MyEmail.TextBody="Testing one two three."
    
    MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusing")=2
    
    'SMTP Server
    MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserver")="smtp.server.com"
    
    'SMTP Port
    MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpserverport")=25 
    
    MyEmail.Configuration.Fields.Update
    MyEmail.Send
    
    set MyEmail=nothing
    

    If your SMTP server requires a username and password then paste these lines in above the MyEmail.Configuration.Fields.Update line:

    'SMTP Auth (For Windows Auth set this to 2)
    MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate")=1
    'Username
    MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendusername")="username" 
    'Password
    MyEmail.Configuration.Fields.Item ("http://schemas.microsoft.com/cdo/configuration/sendpassword")="password"
    

    More information on using CDO to send email with VBScript can be found on the link below: http://www.paulsadowski.com/wsh/cdo.htm

    0 讨论(0)
提交回复
热议问题