I am trying to trigger an email from my lotus notes using javascript. When I am trying to run the code as a .html file from my system. Its working absolutely fine. But when I include the same code in an application and try to run the same using http://localhost:portno , I am getting error that "ActivexObject cannot be resolved to a type".
The script is as given below:
<script language="javascript" type="text/javascript">
function SendScriptMail() {
var mToMail = document.getElementById('txtMailId').value
var mSub = document.getElementById('txtSubject').value
var mMsg = document.getElementById('txtContent').value
var Session;
var Maildb;
var UI;
var MailDoc;
try {
// Create the Activex object for NotesSession
var Session = new ActiveXObject('Notes.NotesSession');
//alert(mMsg);
//alert(Session);
if (Session == null) {
throw("NoSession");
} else {
// Get mail database
//var UserName = Session.UserName;
//MailDbName = UserName.substring(0,1) + UerName.substring(UserName.indexOf( " " ,1) + 1 ,UserName.length) + ".nsf"
Maildb = Session.GetDatabase("", "");
//alert("VCA10177.nsf" + UserName);
Maildb.OPENMAIL();
if (Maildb == null) {
throw("NoMaildb");
} else {
// Create the ActiveX object for NotesUIWorkspace
UI = new ActiveXObject('Notes.NotesUIWorkspace');
if (UI == null) {
throw("NoUI");
} else {
//alert("jj");
MailDoc=UI.Composedocument(Maildb.SERVER, Maildb.FILEPATH, 'Memo');
//alert(Maildb.SERVER);
if (MailDoc == null) {
throw('NoMailDoc');
} else {
// Populate the fields
MailDoc.Fieldsettext('SendTo', mToMail);
MailDoc.Fieldsettext('Subject', mSub);
// insert message body and place cursor at end of text
MailDoc.Gotofield('Body');
MailDoc.Inserttext(mMsg);
// destroy the objects
Session.Close();
Session = null;
UI = null;
Maildb = null;
MailDoc = null;
}
}
}
}
} catch (err) {
// feel free to improve error handling...
alert('Error while sending mail');
}
}
</script>