I am developing an Outlook plugin using add-in-express. There are two mail account (A) which has granted calendar access to account (B) through delegation. I am developing the plugin for account (B).
Here is what I want to implement.
I open the calendar account of (A) after login to outlook using the credentials of account (B) (as a user, not by C# code). Then double click on some date of the calendar, which leads to open a new inspector window for me.
In the ribbon of the inspector, there is a button coming from my pluging. After user click the button, I need to show the email owner’s (account (A)) email and name in the body of the inspector.
Here is the code for the button
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 = "
Owner's Email : " + ownerEmail
+ "
Owner's Name : " + 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();
}
}
Can you please advise me on this? Thank you.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…