如何在C#.Net中使用Lotus Notes打开新电子邮件

时间:2019-02-11 13:17:11

标签: c# .net email lotus

我正在用C#.Net开发一个小型应用程序。

在此应用程序中,我希望能够打开IBM Lotus Notes应用程序,该应用程序设法通过“ BLOC1”完成,但这是来自“ BLOC2” Lotus Notes崩溃:/

在“ BLOC2”中,您是否必须在InvokeMember中保留“ MailServer”和“ MailFile”?

我真的看不到需要做什么,并且互联网上很少有文档。 所以我在你手中。

回顾一下,我希望Lotus Notes应用程序通过填写例如对象,邮件文本,...来打开和打开新电子邮件。 预先谢谢;)

有我的代码:

    public void ComposeMemo(String sendto, String subject, String body)
    {
        //BLOC1 instantiate a Notes session and workspace
        Type NotesSession = Type.GetTypeFromProgID("Notes.NotesSession");
         Type NotesUIWorkspace = Type.GetTypeFromProgID("Notes.NotesUIWorkspace");
         Object sess = Activator.CreateInstance(NotesSession);
         Object ws = Activator.CreateInstance(NotesUIWorkspace);

        //BLOC2 open current user's mail file
        String mailServer = (String)NotesSession.InvokeMember("GetEnvironmentString", BindingFlags.InvokeMethod, null, sess, new Object[] { "MailServer", true });
        String mailFile = (String)NotesSession.InvokeMember("GetEnvironmentString", BindingFlags.InvokeMethod, null, sess, new Object[] { "MailFile", true });
        NotesUIWorkspace.InvokeMember("OpenDatabase", BindingFlags.InvokeMethod, null, ws, new Object[] { mailServer, mailFile });
        Object uidb = NotesUIWorkspace.InvokeMember("GetCurrentDatabase", BindingFlags.InvokeMethod, null, ws, null);
        Object db = NotesUIWorkspace.InvokeMember("Database", BindingFlags.GetProperty, null, uidb, null);
        Type NotesDatabase = db.GetType();

        //BLOC3 compose a new memo
        Object uidoc = NotesUIWorkspace.InvokeMember("ComposeDocument", BindingFlags.InvokeMethod, null, ws, new Object[] { "", "", "Memo", 0, 0, true });
        Type NotesUIDocument = uidoc.GetType();
        NotesUIDocument.InvokeMember("FieldSetText", BindingFlags.InvokeMethod, null, uidoc, new Object[] { "EnterSendTo", sendto });
        NotesUIDocument.InvokeMember("FieldSetText", BindingFlags.InvokeMethod, null, uidoc, new Object[] { "Subject", subject });
        NotesUIDocument.InvokeMember("FieldSetText", BindingFlags.InvokeMethod, null, uidoc, new Object[] { "Body", body });

        //BLOC4 bring the Notes window to the front
        String windowTitle = (String)NotesUIDocument.InvokeMember("WindowTitle", BindingFlags.GetProperty, null, uidoc, null);
        Interaction.AppActivate(windowTitle);
    }

我还有另一个小问题,就是无法识别“互动”一词:/

0 个答案:

没有答案