如何使用c#windows服务阅读Outlook收件箱邮件 [英] how to read outlook inbox mails using c# windows service
本文介绍了如何使用c#windows服务阅读Outlook收件箱邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
Outlook._Application olApp = new Outlook.Application();
Outlook._NameSpace olNs;
Outlook.MAPIFolder oSents;
olNs = olApp.GetNamespace(MAPI);
oSents = olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.Items oItems;
oItems = oSents .Items;
DateTime RDateTime;
for ( int count = oItems。计数;计算> = 1 ; count--)
{
< span class =code-keyword> try
{
Microsoft.Office.Interop.Outlook._MailItem oMICopy = oItems [count] as Microsoft.Office。 Interop.Outlook._MailItem;
oMICopy =(Outlook._MailItem)oItems [count];
RDateTime = oMICopy.ReceivedTime;
subject = oMICopy.Subject;
string MailBody = oMICopy.HTMLBody;
}
但在c#windows服务中,我无法通过本地连接到Outlook系统accout。
请帮帮我......
解决方案
从这里你可以得到很大的帮助
http:// www。 c-sharpcorner.com/uploadfile/rambab/outlookintegration10282006032802am/outlookintegration.aspx [ ^ ]
如何使用c#读取Outlook的电子邮件
in windows forms i am able to read outlook mails using office interop dlls
Outlook._Application olApp = new Outlook.Application();
Outlook._NameSpace olNs;
Outlook.MAPIFolder oSents;
olNs = olApp.GetNamespace("MAPI");
oSents = olNs.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
Outlook.Items oItems;
oItems = oSents .Items;
DateTime RDateTime;
for (int count = oItems.Count; count >= 1; count--)
{
try
{
Microsoft.Office.Interop.Outlook._MailItem oMICopy = oItems[count] as Microsoft.Office.Interop.Outlook._MailItem;
oMICopy = (Outlook._MailItem)oItems[count];
RDateTime = oMICopy.ReceivedTime;
subject = oMICopy.Subject;
string MailBody = oMICopy.HTMLBody;
}
But in c# windows services i am unable to connect to outlook with local system accout.
please help me...
解决方案
May be you get great help from here
http://www.c-sharpcorner.com/uploadfile/rambab/outlookintegration10282006032802am/outlookintegration.aspx[^]
how to read emails from outlook using c#
这篇关于如何使用c#windows服务阅读Outlook收件箱邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文