【问题标题】:c# winforms: button to open outlook inbox page (outlook saved in computer)c# winforms: 打开outlook收件箱页面的按钮(outlook保存在电脑中)
【发布时间】:2018-12-03 17:34:20
【问题描述】:

我打算在单击按钮时打开 Outlook 收件箱页面(见图)。我使用下面的代码,但什么也没发生。希望能得到帮助

    private void button6_Click(object sender, EventArgs e)
    {
        Microsoft.Office.Interop.Outlook.Application outlookApplication = new Microsoft.Office.Interop.Outlook.Application(); ;
        Microsoft.Office.Interop.Outlook.AppointmentItem appointmentItem = (Microsoft.Office.Interop.Outlook.AppointmentItem)outlookApplication.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
    }

【问题讨论】:

    标签: outlook


    【解决方案1】:

    我设法解决了我自己的问题。我没有在最初的问题中说明,但我的笔记本电脑中已经下载了 Outlook 应用程序。

    private void button6_Click(object sender, EventArgs e)
    {
        Process.Start("outlook.exe");
    }
    

    感谢大家的建议

    【讨论】:

      【解决方案2】:

      我检查了您的代码没有问题。因此,您需要跟踪您的 WindowsForm APP 的错误消息并确认关闭您的 Outlook。一般情况下,您可能会收到有关 COM ID 问题的错误。

      请参考以下链接:

      How to open Outlook new mail window c#

      代码:

      Outlook.Application oApp    = new Outlook.Application ();
      Outlook._MailItem oMailItem = (Outlook._MailItem)oApp.CreateItem ( Outlook.OlItemType.olMailItem );
      oMailItem.To    = address;
      // body, bcc etc...
      oMailItem.Display ( true );
      

      调试错误:

      new Outlook.Application() thorws error if Outlook app is running

      【讨论】:

      • 嗨,Simon,我检查了上面的链接并按照 dcomcnfg 进行操作,但我找不到 Outlook 邮件附件,所以可能不是 COM 问题?实际上我上面的代码,一旦我按下按钮,我的任务栏就会弹出一个窗口,说明:另一个程序正在使用 Outlook。要断开程序并退出 Outlook,请单击 Outlook 图标,然后单击立即退出。实际上,我没有打开和outlook,当我检查控制面板时,outlook也没有运行。
      • 可能某些程序正在使用您的 Outlook,我认为您需要检查一下。
      【解决方案3】:

      尝试以下类似的方法(我想不到):

      Outlook.Application oApp    = new Outlook.Application ();
      Outlook.Namespace ns = oApp.GetNamespace("MAPI");
      ns.Logon();
      Outlook.MAPIFolder inbox = ns.GetDEfaultFolder(olFolderInbox);
      if (oApp.Explorers.Count > 0)
      {
        Outlook.Explorer expl = oApp.Explorers[1];
        expl.CurrentFolder = inbox;
      }
      else
      {
        inbox.Display();
      }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2018-12-13
        • 1970-01-01
        • 2010-09-07
        • 1970-01-01
        • 1970-01-01
        • 2010-10-28
        • 1970-01-01
        相关资源
        最近更新 更多