我正在使用以下代码从 MS outlook 2010 中检索不同的邮件参数。但我无法获得抄送电子邮件地址。 MailItem 类的 CC 属性返回名称,而不是电子邮件地址。
NameSpace _nameSpace;
ApplicationClass _app;
_app = new ApplicationClass();
_nameSpace = _app.GetNamespace("MAPI");
object o = _nameSpace.GetItemFromID(EntryIDCollection);
MailItem Item = (MailItem)o;
string HTMLbpdyTest = Item.HTMLBody;
CreationTime = Convert.ToString(Item.CreationTime);
strEmailSenderEmailIdMAPI = Convert.ToString(Item.SenderEmailAddress);
strEmailSenderName = Item.SenderName;
Subject = Item.Subject;
string CCEmailAddress = Item.CC;
请建议,我怎样才能获得抄送电子邮件地址?
请您参考如下方法:
遍历 MailItem.Recipients 集合并为每个 Recipient 对象检查其 Type 属性; olCC 就是你想要的。然后您可以读取 Recipient.Address 属性。
编辑:脱离我的头脑。
foreach (Recipient recip in Item.Recipients)
{
if (recip.Type == OlMailRecipientType.olCC)
{
if (CCEmailAddress.length > 0) CCEmailAddress += ";";
CCEmailAddress += recip.Address;
}
}
