我一直在为Outlook 2013开发一个插件,目前我发现在回复和转发电子邮件时很难找到Outlook 2013中出现的“弹出”窗口的接口类型。
例如:对于新建电子邮件,接口类型为Outlook.MailItem,对于会议请求,接口类型为Outlook.AppointmentItem。
我可以使用什么接口类型来识别在Outlook 2013中回复和转发时弹出的窗口?
发布于 2016-02-29 15:40:08
我的经理和我坐在一起,努力解决这个问题,谢天谢地找到了解决办法。您可以使用以下代码访问“弹出的”回复窗口和转发窗口
//First, declare the interface type of Explorer
public static Outlook.Explorer currentExplorer;
//Create a method to identify the Inline response as a MailItem
private void ThisAddIn_InlineResponse(object Item)
{
if (Item != null)
{
Outlook.MailItem mailItem = Item as Outlook.MailItem;
}
}
//Direct to the ThisAddIn_Startup() method and add an event handler for the Inline Response Method
currentExplorer.InLineResponse += ThisAddIn_InLineResponse;
//Access the popped in reply and forward window where required
object item = null;
item = currentExplorer.ActiveInlineResponse;发布于 2016-02-24 09:25:07
当您回复或转发邮件项时,新项目将是一个MailItem对象。您可以使用折叠代码来确定项目类型:
Object selObject = this.Application.ActiveExplorer().Selection[1];
if (selObject is Outlook.MailItem)
{
Outlook.MailItem mailItem =
(selObject as Outlook.MailItem);
itemMessage = "The item is an e-mail message." +
" The subject is " + mailItem.Subject + ".";
mailItem.Display(false);
}
else if (selObject is Outlook.ContactItem)
{
Outlook.ContactItem contactItem =
(selObject as Outlook.ContactItem);
itemMessage = "The item is a contact." +
" The full name is " + contactItem.Subject + ".";
contactItem.Display(false);
}
else if (selObject is Outlook.AppointmentItem)
{
Outlook.AppointmentItem apptItem =
(selObject as Outlook.AppointmentItem);
itemMessage = "The item is an appointment." +
" The subject is " + apptItem.Subject + ".";
}
else if (selObject is Outlook.TaskItem)
{
Outlook.TaskItem taskItem =
(selObject as Outlook.TaskItem);
itemMessage = "The item is a task. The body is "
+ taskItem.Body + ".";
}
else if (selObject is Outlook.MeetingItem)
{
Outlook.MeetingItem meetingItem =
(selObject as Outlook.MeetingItem);
itemMessage = "The item is a meeting item. " +
"The subject is " + meetingItem.Subject + ".";
}有关详细信息,请参阅如何:以编程方式确定当前Outlook项。
此外,您还可以考虑检查MailItem类的MailItem属性。MessageClass属性将该项链接到它所基于的窗体。选择项时,Outlook将使用消息类定位窗体并公开其属性,如“回复”命令。
https://stackoverflow.com/questions/35583132
复制相似问题