我正在为 Outlook 构建一个共享插件。
在代码内部,我正在使用MailItem.Reply()方法创建回复电子邮件并稍后将其丢弃。我正在使用它来获取来自 Exchange 服务器的电子邮件的发件人电子邮件地址。
它在 Outlook 2007 上运行良好。但对于 Outlook 2010,回复方法似乎打开了邮件编辑器窗口。
我在Windows 7上。
有什么方法可以抑制该窗口或根据 Outlook 版本编写单独的代码?
我正在为 Outlook 构建一个共享插件。
在代码内部,我正在使用MailItem.Reply()方法创建回复电子邮件并稍后将其丢弃。我正在使用它来获取来自 Exchange 服务器的电子邮件的发件人电子邮件地址。
它在 Outlook 2007 上运行良好。但对于 Outlook 2010,回复方法似乎打开了邮件编辑器窗口。
我在Windows 7上。
有什么方法可以抑制该窗口或根据 Outlook 版本编写单独的代码?
如果您打算丢弃消息 - 不要一开始就创建它(除非您打算发送消息,否则不要使用Reply())。您可以使用Recipient该类以最少的资源利用率来解析 Exchange 用户的电子邮件地址。
string senderEmail = string.Empty;
Outlook.Recipient recipient = mailItem.Application.Session.CreateRecipient(mailItem.SenderEmailAddress);
if (recipient != null && recipient.Resolve() && recipient.AddressEntry != null)
{
Outlook.ExchangeUser exUser = recipient.AddressEntry.GetExchangeUser();
if (exUser != null && !string.IsNullOrEmpty(exUser.PrimarySmtpAddress))
senderEmail = exUser.PrimarySmtpAddress;
}