Click here to Skip to main content
13,141,286 members (81,852 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


8 bookmarked
Posted 25 Jul 2008

Automate Client Lotus Mail using JavaScript

, 27 Jan 2009
Rate this:
Please Sign up or sign in to vote.
Send mail through Lotus Notes using JavaScript


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.


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; 
        // Create the Activex object for NotesSession 
        Session = new ActiveXObject('Notes.NotesSession'); 
        if(Session !=null) 
            // Get the user name to retrieve database 
            UserName = Session.UserName; 
            // Retrieve database from username 
            MailDbName = UserName.substring(0,1) + UerName.substring(
                UserName.indexOf( " " ,1) + 1 ,UserName.length) + ".nsf" 
            // Get database 
            Maildb = Session.GetDatabase("", MailDbName); 
            // open the database 
            if(Maildb.IsOpen != true) 
            // Create the mail document 
            MailDoc = Maildb.CREATEDOCUMENT(); 
            // From email id (Username) 
            MailDoc.Form = 'Memo'; 
            // To email id 
            MailDoc.sendto = mToMail; 
            // Subject of the mail 
            MailDoc.Subject = mSub; 
            // Content of the mail 
            MailDoc.Body = mMsg 
                // if you want to save message on send, give true here 
                MailDoc.SAVEMESSAGEONSEND = false; 
            // send the mail (check ensure the internet connection) 
            // save the mail in draft (no need of internet connection) 
            MailDoc.Save(false, true); 
            // destroy the objects 
            Maildb = null; 
            MailDoc = null; 
            AttachME = null; 
            EmbedObj = null; 
            Session = null; 
            alert('Mail sent successfully'); 
            alert('Mail not sent'); 
        if(err == '[object Error]') 
            alert('Error while sending mail,
		Please check Lotus Notes installed in your system'); 
            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”.


This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


About the Author

Mohamed Ishak
Team Leader Transpose solutions pvt Ltd
India India
basically I am a windows application developer and working in microsoft technologies.I have more than 5 year of experience in windows application development.Now i have moved to web development world.I have much more intrest in embedded software development.

Currently i am working for Transpose solutions as a project lead

You may also be interested in...


Comments and Discussions

QuestionNot able to implement it Pin
Member 972459229-Oct-13 19:38
memberMember 972459229-Oct-13 19:38 
QuestionResetting the Body Pin
MadhuGowdaBT12-Feb-13 2:31
memberMadhuGowdaBT12-Feb-13 2:31 
QuestionAdding attachment to Lotus Notes using Javascript Pin
MadhuGowdaBT12-Feb-13 1:54
memberMadhuGowdaBT12-Feb-13 1:54 
GeneralHTML body content and one Bug in code Pin
Tomastest6-Jul-10 20:40
memberTomastest6-Jul-10 20:40 
GeneralRe: HTML body content and one Bug in code Pin
Mohamed Ishak14-Sep-10 1:15
memberMohamed Ishak14-Sep-10 1:15 
GeneralMaildoc.Form problem Pin
GablaHabla19-Mar-10 0:34
memberGablaHabla19-Mar-10 0:34 
GeneralRe: Maildoc.Form problem Pin
Mohamed Ishak30-Mar-10 18:57
memberMohamed Ishak30-Mar-10 18:57 
GeneralGetting Error Pin
Tharikaishu8-Dec-09 16:02
memberTharikaishu8-Dec-09 16:02 
GeneralRe: Getting Error [modified] Pin
Mohamed Ishak5-Jan-10 2:55
memberMohamed Ishak5-Jan-10 2:55 
GeneralSend to multiple recepients Pin
divya.katti30-Sep-09 23:05
memberdivya.katti30-Sep-09 23:05 
GeneralRe: Send to multiple recepients Pin
Mohamed Ishak5-Jan-10 3:17
memberMohamed Ishak5-Jan-10 3:17 
GeneralIn the name of God Pin
Christian Graus18-Sep-09 11:34
mvpChristian Graus18-Sep-09 11:34 
QuestionLotus notes? Pin
Jim Crafton18-Sep-09 10:25
memberJim Crafton18-Sep-09 10:25 
GeneralMy vote of 1 Pin
CPAV27-Jan-09 7:40
memberCPAV27-Jan-09 7:40 
Generaltried the code but it is giving error Pin
Member 248908430-Dec-08 1:38
memberMember 248908430-Dec-08 1:38 
GeneralRe: tried the code but it is giving error Pin
Mohamed Ishak26-Jan-09 22:32
memberMohamed Ishak26-Jan-09 22:32 
GeneralRe: tried the code but it is giving error Pin
Mohamed Ishak27-Jan-09 2:56
memberMohamed Ishak27-Jan-09 2:56 
GeneralRe: Pin
Mohamed Ishak31-Jan-09 1:31
memberMohamed Ishak31-Jan-09 1:31 
GeneralRe: tried the code but it is giving error Pin
dramesh1233-Mar-09 23:13
memberdramesh1233-Mar-09 23:13 
GeneralRe: tried the code but it is giving error Pin
Mohamed Ishak31-Jan-09 1:06
memberMohamed Ishak31-Jan-09 1:06 
GeneralAttachments and multiple recipients Pin
Fpoma13-Dec-08 17:59
memberFpoma13-Dec-08 17:59 
GeneralRe: Attachments and multiple recipients Pin
Mohamed Ishak31-Jan-09 1:02
memberMohamed Ishak31-Jan-09 1:02 
GeneralFormatting Pin
leckey25-Jul-08 4:12
memberleckey25-Jul-08 4:12 
GeneralRe: Formatting Pin
Mohamed Ishak27-Jul-08 17:55
memberMohamed Ishak27-Jul-08 17:55 
GeneralRe: Formatting Pin
mrmroshan13-Jan-13 21:46
membermrmroshan13-Jan-13 21:46 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

Permalink | Advertise | Privacy | Terms of Use | Mobile
Web01 | 2.8.170915.1 | Last Updated 27 Jan 2009
Article Copyright 2008 by Mohamed Ishak
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid