本文介绍了访问日历数据Lotus Notes C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试访问Lotus Domino数据库.可以用C#完成吗?有一些我可以看的例子吗?

I'm trying to access a Lotus Domino database. Can it be done with C#? Are there some examples out there that I could look at?

推荐答案

这里有很多示例,只需尝试搜索即可.这个例子可以帮助您入门:

There are lots of examples out there, just try searching for it. This example could get you started:

//This DLL you've got to add under Project-> Add Reference --> COM Tab --> Lotus Domino Objects
//Standard Path for this DLL is: "C:\Program Files\Notes\domobj.tlb"
using Domino;   //domobj.tlb*
...

try
{
    //-------------------------------------------
    //!!Important!!
    //Before 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.id" 
    // has to be in the main Lotus Notes folder
    //--------------------------------------------    

    //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
    LNSession.Initialize("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) 
    LNDocument.ReplaceItemValue("$PublicAccess","1");    

    //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
    MessageBox.Show(e1.Message);
}
...

这篇关于访问日历数据Lotus Notes C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-26 21:28