Microsoft Jscript Email Module?

后端 未结 1 935
北恋
北恋 2021-01-27 02:34

I was wondering if there is an Email module for MS Jscript (not Jscript .net) similar to the one in python?

相关标签:
1条回答
  • 2021-01-27 03:01

    You can use the Collaboration Data Objects (CDO) COM API.

    Here's how you can send a text e-mail using CDO:

    SendEMail("from@example.com", "to@example.com", "Subject", "Text body"); 
    
    function SendEMail(from, to, subject, body)
    {
      try
      {
        var oMsg      = new ActiveXObject("CDO.Message");
        oMsg.From     = from;
        oMsg.To       = to;
        oMsg.Subject  = subject;
        oMsg.TextBody = body;
        oMsg.Send(); 
      }
      catch(e)
      {
        WScript.Echo("Error: " + e.description);
      }
    }
    

    This page provides some more CDO usage examples (they're in VBScript, but should help you get the idea). See also the CDO Reference at MSDN.

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