【问题标题】:How to open a new mail with Lotus c# (.Net)如何使用 Lotus c# (.Net) 打开新邮件
【发布时间】:2019-02-11 10:03:59
【问题描述】:

我目前正在用 C# 开发一个小型应用程序。 Net 允许执行不同的任务,但在我的一项任务中,我必须从 Lotus 打开一个新的默认邮件。但是我没有找到太多关于它的文档,所以我有点迷茫,这就是我在你手中的原因:/ 所以我只需要能够使用新的默认电子邮件打开 Lotus。 提前致谢;)

【问题讨论】:

  • 您想打开一个新的电子邮件帐户或打开连接到一个邮件帐户的 Lotus notes 应用程序/网站?
  • 我只想运行应用程序并创建(不发送,只是打开)一封新电子邮件,其中已经包含对象;)
  • 好的答案如下

标签: c# .net email lotus


【解决方案1】:

我建议您使用 selenium 网络驱动程序访问他们的网站并自动创建一个电子邮件帐户。

自己操作应用程序可能非常复杂,您可以使用 .NET windows Input Simulator Nugat 包来模拟用户对应用程序的输入或使用 windows API 直接写入内存。

我认为 Lotus 没有支持的方式来做到这一点。

但如果您可以使用 Gmail,那么您可以使用 Gmail API https://developers.google.com/gmail/api/guides/ 使用 .NET httpClient 与之交互。 并创建一个 Gmail 帐户 https://developers.google.com/admin-sdk/directory/v1/guides/manage-users

【讨论】:

  • 不幸的是我必须使用Lotus notes,并且我必须能够打开应用程序而不是网站或其他:/但是我在互联网上找到了一段代码半运行,以显示你我会在下面评论我的话题;)
【解决方案2】:
        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[] { mailServer, mailFile, "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);
    }

BLOC1 执行,它打开应用程序,但从 BLOC2 应用程序不再响应,但我不知道为什么,更多在 BLOC4 中无法识别“交互”一词

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-08-06
    • 1970-01-01
    • 1970-01-01
    • 2010-09-15
    • 2013-10-08
    • 1970-01-01
    • 2016-07-29
    相关资源
    最近更新 更多