durs / node-activex

Node.JS Implementaion of ActiveXObject

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Is it possible to create an Outlook object?

mtaberna opened this issue · comments

I am trying to write something similar to the following code:

    var outlook = new ActiveXObject("Outlook.Application");

    message = outlook.CreateItem(0);
    message.Subject = 'Double-Header Today';
    message.Body = 'This is the message body.';
    message.Save();

    message.Display();

And I am getting an error when trying to create an Outlook object ( Error: CreateInstance: Outlook.Application error in server execution)

Does activex support Outlook object?

It seems Outlook instance is possible to initiate via ActiveX if:
a) Outlook is running with superuser permissions
b) Outlook is not running at all

There might be some issues with x86 architecture and processes, I have no idea

The outlook ActiveX works relatively well with node-activex. At least sending a mail form the default account is a 7 liners. Bellow code works identically in cscript.exe and in node.exe

if ( typeof module !== 'undefined' ) module.exports = require('winax/activex');
function Log( aString ) {
	if ( typeof WScript !== 'undefined' ) {
		WScript.Echo( aString );
	} else {
		console.log( aString );
	}
	return;
}

Log( 'Starting...' );
var oApp = new ActiveXObject("Outlook.Application");
var oMail = oApp.CreateItem(0);
oMail.Recipients.Add('someone@somesite.com');
oMail.Subject = 'Test Mail via ActiveX';
oMail.Send();
Log('Sent!');