ivan
  • ivan
  • 100% (Exalted)
  • Administration Topic Starter
14 years ago
JavaScript Example
The following code demonstrates how to parse from, to, cc, subject, body text, attachments of an EML file.



try {
    var oMail = new ActiveXObject("EAGetMailObj.Mail");
    oMail.LicenseCode = "TryIt";

    oMail.LoadFile("d:\\test.eml", false);

    WScript.Echo("From: " + oMail.From.Address);
    WScript.Echo("Subject: " + oMail.Subject);

    var rcpts = new VBArray(oMail.To).toArray();
    for (var i = 0; i < rcpts.length; i++) {
        var rcpt = rcpts[i];
        WScript.Echo("To: " + rcpt.Address);
    }

    var cc_rcpts = new VBArray(oMail.CC).toArray();
    for (var i = 0; i < cc_rcpts.length; i++) {
        var rcpt = cc_rcpts[i];
        WScript.Echo("To: " + rcpt.Address);
    }

    var atts = new VBArray(oMail.Attachments).toArray();
    for (var i = 0; i < atts.length; i++) {
        var att = atts[i];
        WScript.Echo("Attachment: " + att.Name);
        // you can also save the attachment like this
        att.SaveAs("d:\\" + att.Name, true);
    }

    WScript.Echo("Text Body:");
    WScript.Echo(oMail.TextBody);

    WScript.Echo("Html Body:");
    WScript.Echo(oMail.HtmlBody);

}
catch ( err) {
    WScript.Echo(err.description);
}

EXPLORE TUTORIALS

© All Rights Reserved, AIFEI Software Limited & AdminSystem Software Limited.