我正在开发一个Outlook插件使用外接程序.有两个邮件帐户(A)允许通过委托访问帐户(B)。我正在为帐户(B)开发插件。
这里是我想要实现的.
我使用帐户(B)的凭据(以用户身份,而不是通过C#代码)在登录到outlook后打开(A)的日历帐户。然后双击日历的某个日期,这将为我打开一个新的检查窗口。在检验员的丝带里,有一个按钮来自我的插头。用户单击按钮后,我需要显示电子邮件所有者的电子邮件(帐户(A))的电子邮件和名称在正文的检查员。
这里是按钮的代码
private void adxRibBtnDelegateTest_OnClick(object sender, IRibbonControl control, bool pressed)
{
Outlook.Inspector currentInspector = null;
Outlook.AppointmentItem myAppointment = null;
Outlook.MailItem myMailItem = null;
string ownerEmail = string.Empty;
string ownerName = string.Empty;
try
{
currentInspector = Globals.ObjOutlook.ActiveInspector();
myAppointment = currentInspector.CurrentItem as Outlook.AppointmentItem;
myMailItem = currentInspector.CurrentItem as Outlook.MailItem;
Outlook.AppointmentItem appt = currentInspector.CurrentItem as Outlook.AppointmentItem ;
Outlook.MAPIFolder parent = appt.Parent as Outlook.MAPIFolder;
// ToDo:
// Here I need to develop the functionality for getting the delegated account owner's email and name
string body = "\n\nOwner's Email\t: " + ownerEmail
+ "\nOwner's Name\t: " + ownerName;
if (myAppointment != null)
{
myAppointment.Body = body;
}
else if (myMailItem != null)
{
myMailItem.Body = body;
}
}
catch (Exception ex)
{
Debug.DebugMessage(2, "Error in AddNewNationalCall() : " + ex.Message);
}
finally
{
if (myAppointment != null) Marshal.ReleaseComObject(myAppointment);
if (myMailItem != null) Marshal.ReleaseComObject(myMailItem);
if (currentInspector != null) Marshal.ReleaseComObject(currentInspector);
GC.Collect();
}
}你能给我个建议吗?谢谢。
发布于 2015-06-18 13:34:10
Outlook对象模型没有为此提供任何内容。您可以尝试获取Store对象并检查它的名称(请参阅文件夹类的商店属性)。通常,显示名称包含一个电子邮件地址(请参阅DisplayName),但它不是万能的。
我建议使用任何低级别的属性查看器工具,如MFCMAPI或OutlookSpy。它们允许观察您可以使用PropertyAccessor类访问的低级属性值(以及OOM)。Outlook只是扩展的MAPI的一个大型包装器。
https://stackoverflow.com/questions/30911510
复制相似问题