Reputation: 196499
I have the following code to popup an outlook apptitem. It works great except i can't see the actual attendees textbox on the popup unless i click "Invite Attendees". When i click on that button on the appt item it does show the list of people that i have populated below.
public void BookAppt(List<string> rooms, DateTime startTime, DateTime endTime)
{
var PacktAppointmentItem = (Microsoft.Office.Interop.Outlook.AppointmentItem)Globals.ThisAddIn.Application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
PacktAppointmentItem.Subject = "Test Meeting";
PacktAppointmentItem.Location = "My Room";
PacktAppointmentItem.Start = startTime;
PacktAppointmentItem.End = endTime;
PacktAppointmentItem.Body = "Test Meeting";
PacktAppointmentItem.RequiredAttendees = String.Join(";", rooms);
PacktAppointmentItem.Display(true);
}
Is there any way to how that textbox of attendees shown automatically without having to click on the "Invite Attendees" button? Also, is there anyway to programatically call "Check names" so the attendees are resolved?
Upvotes: 2
Views: 1516
Reputation: 1595
I think what you want is a MeetingItem, and not an AppointmentItem. You can't directly create a MeetingItem, but you're almost there anywhere: just add this line in your code:
PacktAppointmentItem.MeetingStatus = Outlook.OlMeetingStatus.olMeeting;
So your final code should like
var PacktAppointmentItem = (Microsoft.Office.Interop.Outlook.AppointmentItem)Globals.ThisAddIn.Application.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem);
PacktAppointmentItem.Subject = "Test Meeting";
PacktAppointmentItem.Location = "My Room";
PacktAppointmentItem.Start = DateTime.Now;
PacktAppointmentItem.MeetingStatus = Outlook.OlMeetingStatus.olMeeting;
PacktAppointmentItem.End = DateTime.Now.AddHours(1.0);
PacktAppointmentItem.Body = "Test Meeting";
PacktAppointmentItem.RequiredAttendees = String.Join(";", rooms);
PacktAppointmentItem.Display(true);
Quick background: From microsoft: http://msdn.microsoft.com/en-us/library/office/microsoft.office.interop.outlook.meetingitem(v=office.14).aspx
Unlike other Microsoft Outlook objects, you cannot create this [e.g. MeetingItem] object. It is created automatically when you set the MeetingStatus property of an AppointmentItem object to olMeeting and send it to one or more users. They receive it in their inboxes as a MeetingItem.
Upvotes: 1