在不打开 Outlook 应用程序的情况下阅读电子邮件 [英] Reading e-mail without Outlook app open

查看:25
本文介绍了在不打开 Outlook 应用程序的情况下阅读电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这就是我使用 C# 阅读电子邮件的方式:

Thats what I am using to read e-mail using C#:

outLookApp.NewMailEx += new ApplicationEvents_11_NewMailExEventHandler(outLookApp_NewMailEx);
            Outlook.NameSpace olNameSpace = outLookApp.GetNamespace("mapi");

olNameSpace.Logon("xxxx", "xxxxx", false, true);
Outlook.MAPIFolder oInbox  = olNameSpace.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.Items oItems  = oInbox.Items;
MessageBox.Show("Total : " + oItems.Count); //Total Itemin inbox
 oItems = oItems.Restrict("[Unread] = true");
 MessageBox.Show("Total Unread : " + oItems.Count); //Unread Items
 Outlook.MailItem oMsg;


 Outlook.Attachment mailAttachement;
 for (int i = 0; i < oItems.Count; i++)
 {
     oMsg = (Outlook.MailItem)oItems.GetFirst();

     MessageBox.Show(i.ToString());

    MessageBox.Show(oMsg.SenderName);
    MessageBox.Show(oMsg.Subject);
    MessageBox.Show(oMsg.ReceivedTime.ToString());
    MessageBox.Show(oMsg.Body);

我面临的问题是此应用程序仅在机器上打开 Outlook 时才有效.如果 Outlook 关闭,则会引发异常:

The problem that I am facing is this application only works if the Outlook is open on the machine. If Outlook is closed it throws an exception:

服务器不可用.如果这种情况持续存在,请与您的管理员联系.

The server is not available. Contact your administrator if this condition persists.

无论如何,我可以在打开 Outlook 的情况下阅读电子邮件吗?

Is there anyway I can read e-mail with Outlook open?

推荐答案

您可能会遇到 this 当 Outlook 关闭时.

You'll likely run into this when Outlook is closed.

还关注 本教程 将确保您执行所有正确的步骤.

Also following this tutorial will ensure you're doing all the right steps part and parcel.

祝你好运!

这篇关于在不打开 Outlook 应用程序的情况下阅读电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆