Read Lotus Notes documents and items from NSF file with C#

时光总嘲笑我的痴心妄想 提交于 2019-12-22 05:39:11

问题


How can I get all Lotus Notes documents (e.g. mails and their content) from a Lotus Notes inbox from an NSF Files with C# and the usage of interop.domino.dll?

I want to use the following snippet:

Domino.NotesSession m_session = null;

...

this.m_session = new Domino.NotesSession();
this.m_session.Initialize("");

Domino.NotesDatabase db = null;
this.m_session.GetDatabase("", "C:\test.nsf", false);

Domino.NotesDocumentCollection col = db.AllDocuments;

for (int i = 0; i < col.Count; ++i)
{
         Domino.NotesDocument doc = col.GetNthDocument(i);

         ...
}

How can I access the items of each document? For example I want subject, who, date, time,...

How can I iterate throug all items of a document?

How can I extract attachments?

Is the NotesSQL ODBC driver a good alternative to the COM API?


回答1:


This should work. The GetItemValue method in Lotusscript returns a value array, but usually you're just going to need the value at the first index. I'm not sure if it works the same way with COM, but the debugger can help you figure that out.

Also if you're processing a lot of documents it is much faster to iterate using the GetFirstDocument/GetNextDocument methods than it is to use the GetNthDocument method.

Domino.NotesDocument doc = col.GetFirstDocument(doc);
while (doc != null) {

     string subject = doc.GetItemValue("subject")[0];
     string who = doc.GetItemValue("sendto")[0];

     Domino.NotesDocument doc = col.GetNextDocument(doc);
}


来源:https://stackoverflow.com/questions/4267444/read-lotus-notes-documents-and-items-from-nsf-file-with-c-sharp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!