Introduction
In the name of God, I am starting this white paper. Some of the programmers have written articles for automating Lotus Notes (send email through Lotus Notes) in Windows application. But when we want to send email through Lotus Notes on the client side, we have the choice of Java scripting.
This JavaScript directly automates the client side Lotus client. The basic idea is to get the client side Lotus database and inject your mail into the mail database. I will not write more here. But the script will do.
Implementation
Here I have listed out the script for sending email through Lotus Notes. First we have to create ActivexObject for Lotus.NotesSession
, then we have to use the methods of that object to send mail. We can have several methods in activeX object to automate Lotus Notes. We have to create a mail document object to create the mail subject and content.
JavaScript Code
function SendScriptMail(mToMail,mSub,mMsg)
{
var Maildb;
var UserName;
var MailDbName;
var MailDoc;
var AttachME;
var Session;
var EmbedObj;
var server;
try
{
Session = new ActiveXObject('Notes.NotesSession');
if(Session !=null)
{
UserName = Session.UserName;
MailDbName = UserName.substring(0,1) + UerName.substring(
UserName.indexOf( " " ,1) + 1 ,UserName.length) + ".nsf"
Maildb = Session.GetDatabase("", MailDbName);
if(Maildb.IsOpen != true)
{
Maildb.OPENMAIL();
}
MailDoc = Maildb.CREATEDOCUMENT();
MailDoc.Form = 'Memo';
MailDoc.sendto = mToMail;
MailDoc.Subject = mSub;
MailDoc.Body = mMsg
MailDoc.SAVEMESSAGEONSEND = false;
MailDoc.Send(true);
MailDoc.Save(false, true);
Maildb = null;
MailDoc = null;
AttachME = null;
EmbedObj = null;
Session.Close();
Session = null;
alert('Mail sent successfully');
}
else
{
alert('Mail not sent');
}
}
catch(err)
{
if(err == '[object Error]')
{
alert('Error while sending mail,
Please check Lotus Notes installed in your system');
}
else
{
alert('Error while sending mail');
}
}
}
Limitation of Usage
Important Note: For security reasons, Internet Explorer does not allow scripts to create ActivexObject on the client side. So the script will not work. To avoid this, we have to change the internet security settings, go to “Internet Options” from tools menu, then go to “Security” tab, select “local intranet” or “internet”, click “Custom Level” button, then the security settings dialog will open, select “Initialize and script ActiveX controls not marked as safe for scripting”, select “enable” or “Prompt” option. Changing this, you have to lose your security on the internet. So better change the same settings in “Trusted Sites” and add your page into “Trusted Sites”.