我正在尝试回复电子邮件null
时sender.name
SenderName
private void ThisAddIn_Startup(object sender, System.EventArgs e)
{
currentExplorer = this.Application.ActiveExplorer();
currentExplorer.SelectionChange += new Outlook.ExplorerEvents_10_SelectionChangeEventHandler(CurrentExplorer_Event);
}
private void CurrentExplorer_Event()
{
if (this.Application.ActiveExplorer().Selection.Count == 1
&& this.Application.ActiveExplorer().Selection[1] is Outlook.MailItem)
{
if (mailItem != null)
{
((Outlook.ItemEvents_10_Event)mailItem).Reply -= new Outlook.ItemEvents_10_ReplyEventHandler(MailItem_Reply);
}
mailItem = this.Application.ActiveExplorer().Selection[1];
((Outlook.ItemEvents_10_Event)mailItem).Reply += new
Outlook.ItemEvents_10_ReplyEventHandler(MailItem_Reply);
}
}
void MailItem_Reply(Object response, ref bool cancel)
{
Outlook.MailItem mailItem = (Outlook.MailItem)response;
mailItem.GetInspector.Activate();
string u = mailItem.Subject;
string x = mailItem.Sender.Name;
string r = mailItem.SenderName;
mailItem.Body = "Hi " + x.Split(' ')[0]+ "\n" + mailItem .Body;
}
我也得到
方法“Microsoft.Office.Interop.Outlook._Inspector.Activate()”和非方法“Microsoft.Office.Interop.Outlook.InspectorEvents_10_Event.Activate”之间存在歧义。使用方法组。
有人可以告诉我如何正确执行此操作,以便我可以自动回复例如发件人姓名并消除这种歧义吗?