Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
This sample shows how OOM can be used with JavaScript from the command line. Use cscript to launch it - this will cause the script to write the output to the command window.
// Use this command line: cscript test.js
function test()
{
WScript.Echo('Start -------------');
try {
var outlook = new ActiveXObject('Outlook.Application');
var email = outlook.CreateItem(0);
//add some recipients
email.Recipients.Add('danba@microsoft.com').Type = 1; //1=To
//subject and attachments
email.Subject = 'Javascript test';
WScript.Echo('Before Add()');
email.Attachments.Add('https://contoso/documents/wonderful.pdf', 1); //1=Add by value so outlook downloads the file from the url
WScript.Echo('After Add()');
WScript.Echo('Before display()');
email.Display();
WScript.Echo('After display()');
}
catch (error)
{
WScript.Echo("Error - name:" + (error).name + " \nMessage:" + error.message);
}
WScript.Echo('End -------------');
}
test();