Click here to Skip to main content
13,259,539 members (70,630 online)
Click here to Skip to main content
Add your own
alternative version

Tagged as


4 bookmarked
Posted 25 Nov 2010

How to Add a Lotus Notes Calendar Entry with C#

, 10 Jan 2011
Rate this:
Please Sign up or sign in to vote.
How to Add a Lotus Notes Calendar Entry with C#

The following code will show you how to add an entry in a Lotus Notes Calendar with C#

//This DLL you've got to add under Projekt-> Add Reference --> COM Tab --> Lotus Domino Objects
//Standard Path for this DLL is: "C:\Program Files\Notes\domobj.tlb"
using Domino;   //domobj.tlb*
    //Befor you start, you have to check 2 things
    //1.) Lotus Notes has to run when you start this application
    //2.)The files "notes.ini" and "" 
    //("user" stands for your username) have to be in the folder 
    // "C:\Program Files\Notes" or "C:\Program Files\IBM\Notes" 
    //First, create a new Lotus Notes Session Object
    Domino.NotesSession LNSession = new Domino.NotesSession();
    //Next add a Database and a Document Object (not new)
    Domino.NotesDatabase LNDatabase;
    Domino.NotesDocument LNDocument;
    //Initialize your Session with your Password
    //Connect to your Notes Server and the path of your 
    //.nsf File (in my case its in a subfolder 'mail').
    LNDatabase = LNSession.GetDatabase("Notes-Server", "mail\\user.nsf", false);
    //Create an in memory document in the server database
    LNDocument = LNDatabase.CreateDocument();
    //-------Assign Field Values-------
    //Define Start&End Date+Time of your appointment
    //Year, Month, Day, Hour, Minute and Second
    System.DateTime StartDate = new DateTime(2008, 3, 19, 8, 2, 0);
    System.DateTime EndDate = new DateTime(2008, 3, 19, 8, 5, 0);
    //This Defines that it is an Calendar Entry
    LNDocument.ReplaceItemValue("Form", "Appointment");
    //Type of the appointment, means:
    LNDocument.ReplaceItemValue("AppointmentType", "0");
    //0 = Date, Appointment           
    //1 = Anniversary
    //2 = All Day Event (Do Not Set Time Here!)
    //3 = Meeting
    //4 = Reminder
    //5 = Date (Special, experimental!)    
    // Title of your entry
    LNDocument.ReplaceItemValue("Subject", "hello world");
    // Set Confidential Level (Public=1 or Private=0) 
    //Add Start&End Time of your event
    LNDocument.ReplaceItemValue("CALENDARDATETIME", StartDate);
    LNDocument.ReplaceItemValue("StartDateTime", StartDate);
    LNDocument.ReplaceItemValue("EndDateTime", EndDate);
    LNDocument.ReplaceItemValue("StartDate", StartDate);
    LNDocument.ReplaceItemValue("MeetingType", "1");
    //Infos in The Body
    LNDocument.ReplaceItemValue("Body", "Body Text Body Text ...");
    //Add an alarm to your appointment
    LNDocument.ReplaceItemValue("$Alarm", 1);
    LNDocument.ReplaceItemValue("$AlarmDescription", "hello world (alarm)");
    LNDocument.ReplaceItemValue("$AlarmMemoOptions", "" );
    //5 = Time (in minutes) before alarm goes on
    LNDocument.ReplaceItemValue("$AlarmOffset", 5);
    LNDocument.ReplaceItemValue("$AlarmSound", "tada");
    LNDocument.ReplaceItemValue("$AlarmUnit", "M");
    //This saves your Document in the Notes Calendar
    LNDocument.ComputeWithForm(true, false);
    LNDocument.Save(true, false, false);
    //On success, you'll see an info message;
    MessageBox.Show("Calendar Entry Successfully Added!", "Info", 
        MessageBoxButtons.OK, MessageBoxIcon.Information);
catch (Exception e1)
    //On error you'll see an error message


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


About the Author

United States United States
This member doesn't quite have enough reputation to be able to display their biography and homepage.

You may also be interested in...

Comments and Discussions

QuestionLotus Calendar Entry with C# ERRROR Object reference not set to an instance of an object Pin
Juan Eduardo Galvez Bustamante7-May-13 6:27
memberJuan Eduardo Galvez Bustamante7-May-13 6:27 
GeneralThis adds the event to the calendar. However, the alarm doe... Pin
Chris Goedde22-Nov-11 12:03
memberChris Goedde22-Nov-11 12:03 
GeneralHow can i add attendees to calendar? i tried adding it but i... Pin
Haseena879-Nov-11 22:01
memberHaseena879-Nov-11 22:01 
GeneralReason for my vote of 5 Because using Lotus Notes sucks, you... Pin
meaningoflights9-Dec-10 21:13
membermeaningoflights9-Dec-10 21:13 
GeneralI gladly shared it ;). I searched for this solution about 2 ... Pin
Minuert30-Nov-10 3:32
memberMinuert30-Nov-10 3:32 
GeneralThank you for sharing this with us even though Lotus Notes s... Pin
Slacker00729-Nov-10 6:07
memberSlacker00729-Nov-10 6:07 

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
Web04 | 2.8.171114.1 | Last Updated 10 Jan 2011
Article Copyright 2010 by Minuert
Everything else Copyright © CodeProject, 1999-2017
Layout: fixed | fluid