问题描述
我希望阅读一份展望信息.
使用mapi,我可以读取部分数据.
例如,我能够读取Serer邮件,主题邮件,正文,但无法读取邮件的日期时间和邮件抄送.我已经下载了此源项目在C#中读取Outlook MSG文件 [ ^ ]
但是这里不使用邮件日期时间发件人和抄送.
我可以通过哪种方式获取此数据?
我使用OutlookStorage.Message
消息,但在消息中找不到我的信息.
在此变量中,我仅找到了正文,主题,显示名称,收件人等.
非常感谢
Hi,
I wish to read an outlook message.
With mapi I am able to read a part of data.
For example I am able to read serer mail, subject mail, body text but I am not able to read datetime of mail and Cc of mail. I have downloaded this source project Reading an Outlook MSG File in C#[^]
But here doesn''t use mail date time sender and CC.
In which way can i obtain this data??
I use OutlookStorage.Message
message but I have not found my information in message.
In this variable I have found only body text, subject, displayname, recipients etc.
Thanks a lot
推荐答案
using Office = Microsoft.Office.Core;
using Outlook = Microsoft.Office.Interop.Outlook;
Outlook.Application outlook = new Outlook.ApplicationClass();
Outlook.NameSpace ns = outlook.GetNamespace("Mapi");
Outlook.Recipient oRecip = ns.CreateRecipient("INBOX");
oRecip.Resolve();
if (oRecip.Resolved)
{
Outlook.MAPIFolder oInbox = ns.GetSharedDefaultFolder(oRecip, Outlook.OlDefaultFolders.olFolderInbox);
//Outlook.Items oInboxMsgs = oInbox.Items;
//MessageBox.Show(oInboxMsgs.Count.ToString());
if (oInbox.Items.Count > 0 && oInbox.Items.Count != null)
{
for (int i = 1; i <= oInbox.Items.Count; i++)
{
//item = (Microsoft.Office.Interop.Outlook.PostItem)oInbox.Items[i];
if (oInbox.Items[i] is Outlook.MailItem)
{
Outlook.MailItem mailItem = oInbox.Items[i] as Outlook.MailItem;
ProcessMailItem(mailItem);
mailItem.UnRead = false;
}
}
}
}
这样,您可以在Office互操作中使用Mailitem对象,该对象具有您需要/想要的所有信息
This way you can use the Mailitem object in the Office interop which has all the info you need/want
这篇关于[C#]我如何阅读日期时间和抄送的Outlook信息?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!