阅读没有Outlook应用程序打开的电子邮件 [英] Reading e-mail without Outlook app open

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

问题描述

这是我使用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); //总Itemin收件箱
oItems = oItems.Restrict([Unread] = true);
MessageBox.Show(Total Unread:+ oItems.Count); //未读项目
Outlook.MailItem oMsg;


Outlook.Attachment mailAttachement; (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已关闭,则会抛出异常:


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


有没有可以看到Outlook打开的电子邮件?

$ b你可能会碰到这个



还跟着本教程将会确保你正在做所有正确的步骤部分和包裹。



最好的运气!


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);

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.

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

解决方案

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.

Best of luck!

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

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