我想弄清楚如何通过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