我想弄清楚如何通過C#獲取當前在Lotus Notes上打開的文檔,但是我不能。儘管我在Google上搜索了半天,但找不到任何有用的信息。獲取當前打開的文檔
用我的代碼我得到我想要的視圖,我想要的數據庫等,但我只想獲得打開的文檔。我嘗試了類似IsUIDocOpen的東西,但沒有一個完整的集合包含它爲true。
有人知道打開的文檔和未打開的文檔在Domino API之間是否有任何不同嗎?我的解決方法是獲取電子郵件的主題和電子郵件的大小,並比較每個電子郵件和匹配時間,獲取條目ID,然後獲取我需要的信息 - 但這需要很長時間,特別是當收件箱很大時。
有什麼建議嗎?
這裏是我的代碼:
NotesSession session = new NotesSession();
session.Initialize(sPassword);
notedb = session.GetDatabase(server, filename, false);
if (notedb.IsOpen)
{
mailView = notedb.GetView("$Inbox");
mailDoc = mailView.GetLastDocument();
//mailDoc = mailView.GetDocumentByKey();
try
{
while (mailDoc != null)
{
NotesItem item = mailDoc.GetFirstItem("From");
if (item != null)
{
MessageBox.Show("From = " + item.Text);
}
}
}
}
解決方法:應該是這樣的:mailDoc = mailView.GetCurrentDocument();
//但顯然這種方法不存在:d
=========== ================================================== ======================== 解決方案代碼:
Type NotesUIWorkspaceType = Type.GetTypeFromProgID("Notes.NotesUIWorkspace", true);
object workspace = Activator.CreateInstance(NotesUIWorkspaceType);
object uiDoc = NotesUIWorkspaceType.InvokeMember("CurrentDocument", BindingFlags.GetProperty, null, workspace, null);
Type NotesUIDocument = uiDoc.GetType();
object Subject = NotesUIDocument.InvokeMember("FieldGetText", BindingFlags.InvokeMethod, null, uiDoc, new Object[] { "Subject" });
string subject = "test";
NotesUIDocument.InvokeMember("FieldSetText", BindingFlags.InvokeMethod, null, uiDoc, new Object[] { "Subject", subject });
object Body = NotesUIDocument.InvokeMember("FieldGetText", BindingFlags.InvokeMethod, null, uiDoc, new Object[] { "Body" });
您是使用Domino API還是Lotus Notes Interop COM類?如果您使用的是Domino,它將無法工作:它使您可以訪問Domino服務器上的數據庫,而不是Lotus Notes程序。 – 2013-03-20 15:14:34
哪裏可以找到Lotus Notes Interop COM類?謝謝 – peterpeterson 2013-03-21 08:50:57
看看這裏:http://www.ibm。com/developerworks/lotus/library/domino-msnet/index.html。它適用於VB.Net,但如果我沒有記錯的話,在C#中可以訪問名稱空間中的包裝類,以便創建類。 – 2013-03-21 09:28:36