Creating and Sending Meeting Messages on Behalf of a Principal in Exchange 2010
Last modified: October 14, 2009
Applies to: Exchange Server 2007 | Exchange Server 2010
In Microsoft Exchange Server 2010, you can use delegate access to create and send a meeting invitation on behalf of a principal. Delegate permissions must be set before delegate access is enabled for an account. You can set delegate permissions by using Microsoft Outlook 2010, the Exchange Management Shell, or the Exchange Management Console.
Note
To recipients of messages that are sent by a delegate on behalf of a principal, the sender appears as "Delegate on behalf of Principal."
Delegates operate within their own mailboxes. Messages that are sent by delegates are saved in the delegate’s Sent Items folder.
Example
The following code example shows how a delegate creates and sends a meeting on behalf of another user. In this example, user2 sends a meeting on behalf of user1. User2 is the delegate and user1 is the principal. User3 is a required attendee.
Setting delegate access permission is a prerequisite for this code example. For information about how to set delegate access permission, see Add-MailboxPermission.
static void CreateAndSendMeetingOnBehalfOfPrincipal(ExchangeServiceBinding esb)
{
// Create the request and specify how the item is handled.
CreateItemType request = new CreateItemType();
request.MessageDisposition = MessageDispositionType.SendAndSaveCopy;
request.MessageDispositionSpecified = true;
request.SendMeetingInvitations = CalendarItemCreateOrDeleteOperationType.SendToAllAndSaveCopy;
request.SendMeetingInvitationsSpecified = true;
// Identify the principal's Calendar folder as the target folder for the calendar item.
DistinguishedFolderIdType defCalendarFolder = new DistinguishedFolderIdType();
defCalendarFolder.Id = DistinguishedFolderIdNameType.calendar;
defCalendarFolder.Mailbox = new EmailAddressType();
defCalendarFolder.Mailbox.EmailAddress = "user1@example.com";
TargetFolderIdType target = new TargetFolderIdType();
target.Item = defCalendarFolder;
// Add the destination folder to the request.
request.SavedItemFolderId = target;
// Create the calendar item to start the meeting in one hour.
CalendarItemType calendarItem = new CalendarItemType();
calendarItem.Subject = "Delegate appointment";
calendarItem.Body = new BodyType();
calendarItem.Body.BodyType1 = BodyTypeType.Text;
calendarItem.Body.Value = "This is the text of the delegate appointment.";
calendarItem.Start = DateTime.Now.AddHours(1);
calendarItem.StartSpecified = true;
calendarItem.End = DateTime.Now.AddHours(2);
calendarItem.EndSpecified = true;
calendarItem.LegacyFreeBusyStatus = LegacyFreeBusyType.Busy;
calendarItem.LegacyFreeBusyStatusSpecified = true;
// Add attendee to calendar item.
AttendeeType attendee1 = new AttendeeType();
attendee1.Mailbox = new EmailAddressType();
attendee1.Mailbox.EmailAddress = "user3@RERMAN-dom.extest.microsoft.com";
calendarItem.RequiredAttendees = new AttendeeType[] { attendee1 };
// Add the calendar item to the request.
request.Items = new NonEmptyArrayOfAllItemsType();
request.Items.Items = new ItemType[] { calendarItem };
try
{
// Send the request and get the response.
CreateItemResponseType response = esb.CreateItem(request);
// Get the response messsages.
ResponseMessageType[] rmta = response.ResponseMessages.Items;
foreach (ResponseMessageType rmt in rmta)
{
ArrayOfRealItemsType itemArray = ((ItemInfoResponseMessageType)rmt).Items;
ItemType[] items = itemArray.Items;
// Get the item identifier for the meeting.
foreach (ItemType item in items)
{
Console.WriteLine("Item identifier: " + item.ItemId.Id);
}
}
}
catch
{
// Handle exception.
}
}
User3 receives the meeting invitation. The Organizer and From properties of the meeting invitation are set with the principal's mailbox. The Sender property is set with the delegate's mailbox. The relationship between delegate and principal are expressed in Outlook Web App as "[Sender property] on behalf of [From property]."
This code example was created by using proxy objects that are created by using Microsoft Visual Studio 2005.