Exchange Server TechCenter > Exchange Server Forums > Development > EWS: Meetings SendToNone and SendOnlyToAll behaviour...
Ask a questionAsk a question
 

AnswerEWS: Meetings SendToNone and SendOnlyToAll behaviour...

  • Thursday, November 05, 2009 10:48 AMDanil Novhorodov Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Hello guys,

    I'm trying to simulate Outlook functionality when organizer creates new meeting, invite some attendees, but then clicks "Save changes, but don't send".
    So the meeting creates in organizer calendar folder only without sending any meeting notifications to attendees.
    I just set:

    createItemRequest.SendMeetingInvitations =

    CalendarItemCreateOrDeleteOperationType.SendToNone;

    but this doesn't help. In that case item creates in Outlook just as appointment, NOT meeting. So it seems that one of mandatory condition for creating meeting is always set createItemRequest.SendMeetingInvitations = CalendarItemCreateOrDeleteOperationType.SendOnlyToAll;

    Is it correct? And how can I create meeting without sending notification requests to attendees?

Answers

  • Friday, November 06, 2009 9:50 PMGlen ScalesMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    That is EWS code its for the EWS Managed API which you might want to take a look at as it can save you a lot of time if you doing a lot of EWS coding. To do this with proxy code try something like

                // Create the appointment.
                CalendarItemType appointment = new CalendarItemType();
    
                // Set the properties of the appointment.
                appointment.Start = DateTime.Now;
                appointment.StartSpecified = true;
                appointment.End = DateTime.Now.AddHours(1);
                appointment.EndSpecified = true;
                appointment.Subject = "Planning meeting";
                appointment.Location = "Building 3, Room 311";
                appointment.Body = new BodyType();
                appointment.Body.BodyType1 = BodyTypeType.Text;
                appointment.Body.Value = "Plan the department party.";
    
                // Add required attendees.
                appointment.RequiredAttendees = new AttendeeType[1];
                appointment.RequiredAttendees[0] = new AttendeeType();
                appointment.RequiredAttendees[0].Mailbox = new EmailAddressType();
                appointment.RequiredAttendees[0].Mailbox.EmailAddress = "attendee";
    
                PathToExtendedFieldType PidLidAppointmentStateFlags = new PathToExtendedFieldType();
                PidLidAppointmentStateFlags.DistinguishedPropertySetIdSpecified = true;
                PidLidAppointmentStateFlags.DistinguishedPropertySetId = DistinguishedPropertySetType.Appointment;
                PidLidAppointmentStateFlags.PropertyId = 33303;
                PidLidAppointmentStateFlags.PropertyIdSpecified = true;
                PidLidAppointmentStateFlags.PropertyType = MapiPropertyTypeType.Integer;
                ExtendedPropertyType exProperty = new ExtendedPropertyType();
                exProperty.ExtendedFieldURI = PidLidAppointmentStateFlags;
                exProperty.Item = "1";
    
                appointment.ExtendedProperty = new ExtendedPropertyType[1];
                appointment.ExtendedProperty[0] = exProperty;
                // Create the array of items that will contain the appointment.
                NonEmptyArrayOfAllItemsType arrayOfItems = new NonEmptyArrayOfAllItemsType();
                arrayOfItems.Items = new ItemType[1];
    
                // Add the appointment to the array of items.
                arrayOfItems.Items[0] = appointment;
    
                // Create the CreateItem request.
                CreateItemType createRequest = new CreateItemType();
    
                // The SendMeetingInvitations attribute is required for calendar items.
                createRequest.SendMeetingInvitations =
                      CalendarItemCreateOrDeleteOperationType.SendToNone;
                createRequest.SendMeetingInvitationsSpecified = true;
    
                DistinguishedFolderIdType cfcal = new DistinguishedFolderIdType();
                cfcal.Id = DistinguishedFolderIdNameType.calendar;
                // Add the destination folder to the CreateItem request.
                createRequest.SavedItemFolderId = new TargetFolderIdType();
                createRequest.SavedItemFolderId.Item = cfcal;
    
                // Add the items to the CreateItem request.
                createRequest.Items = arrayOfItems;
    
                // Create the appointment by calling the CreateItem method, which has
                // the side effect of sending invitations to attendees.
                CreateItemResponseType createResponse =
                      esb.CreateItem(createRequest);
    
                // Check the result.
                if (createResponse.ResponseMessages.Items[0].ResponseClass !=
                      ResponseClassType.Success)
                {
                    throw new Exception("EWSWrap.SendAppointment failed.");
                }
    
    Cheers
    Glen

All Replies

  • Friday, November 06, 2009 10:34 AMGlen ScalesMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    You need to set the PidLidAppointmentStateFlags extended property to 1 for a meeting see http://msdn.microsoft.com/en-us/library/cc765762.aspx

    eg

                Appointment apt = new Appointment(service);
                apt.Start = DateTime.Now;
                apt.End = DateTime.Now.AddHours(1);
                apt.Subject = "test 123";
                ExtendedPropertyDefinition PidLidAppointmentStateFlags = new ExtendedPropertyDefinition(DefaultExtendedPropertySet.Appointment, 33303, MapiPropertyType.Integer);
                apt.SetExtendedProperty(PidLidAppointmentStateFlags, "1");
                apt.RequiredAttendees.Add("newattendee");
                apt.Save(SendInvitationsMode.SendToNone);
    
    Cheers
    Glen
  • Friday, November 06, 2009 4:00 PMDanil Novhorodov Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks, but could you post the same code, but for EWS and Exchange 2007 SP1 ?
  • Friday, November 06, 2009 9:50 PMGlen ScalesMVPUsers MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     AnswerHas Code
    That is EWS code its for the EWS Managed API which you might want to take a look at as it can save you a lot of time if you doing a lot of EWS coding. To do this with proxy code try something like

                // Create the appointment.
                CalendarItemType appointment = new CalendarItemType();
    
                // Set the properties of the appointment.
                appointment.Start = DateTime.Now;
                appointment.StartSpecified = true;
                appointment.End = DateTime.Now.AddHours(1);
                appointment.EndSpecified = true;
                appointment.Subject = "Planning meeting";
                appointment.Location = "Building 3, Room 311";
                appointment.Body = new BodyType();
                appointment.Body.BodyType1 = BodyTypeType.Text;
                appointment.Body.Value = "Plan the department party.";
    
                // Add required attendees.
                appointment.RequiredAttendees = new AttendeeType[1];
                appointment.RequiredAttendees[0] = new AttendeeType();
                appointment.RequiredAttendees[0].Mailbox = new EmailAddressType();
                appointment.RequiredAttendees[0].Mailbox.EmailAddress = "attendee";
    
                PathToExtendedFieldType PidLidAppointmentStateFlags = new PathToExtendedFieldType();
                PidLidAppointmentStateFlags.DistinguishedPropertySetIdSpecified = true;
                PidLidAppointmentStateFlags.DistinguishedPropertySetId = DistinguishedPropertySetType.Appointment;
                PidLidAppointmentStateFlags.PropertyId = 33303;
                PidLidAppointmentStateFlags.PropertyIdSpecified = true;
                PidLidAppointmentStateFlags.PropertyType = MapiPropertyTypeType.Integer;
                ExtendedPropertyType exProperty = new ExtendedPropertyType();
                exProperty.ExtendedFieldURI = PidLidAppointmentStateFlags;
                exProperty.Item = "1";
    
                appointment.ExtendedProperty = new ExtendedPropertyType[1];
                appointment.ExtendedProperty[0] = exProperty;
                // Create the array of items that will contain the appointment.
                NonEmptyArrayOfAllItemsType arrayOfItems = new NonEmptyArrayOfAllItemsType();
                arrayOfItems.Items = new ItemType[1];
    
                // Add the appointment to the array of items.
                arrayOfItems.Items[0] = appointment;
    
                // Create the CreateItem request.
                CreateItemType createRequest = new CreateItemType();
    
                // The SendMeetingInvitations attribute is required for calendar items.
                createRequest.SendMeetingInvitations =
                      CalendarItemCreateOrDeleteOperationType.SendToNone;
                createRequest.SendMeetingInvitationsSpecified = true;
    
                DistinguishedFolderIdType cfcal = new DistinguishedFolderIdType();
                cfcal.Id = DistinguishedFolderIdNameType.calendar;
                // Add the destination folder to the CreateItem request.
                createRequest.SavedItemFolderId = new TargetFolderIdType();
                createRequest.SavedItemFolderId.Item = cfcal;
    
                // Add the items to the CreateItem request.
                createRequest.Items = arrayOfItems;
    
                // Create the appointment by calling the CreateItem method, which has
                // the side effect of sending invitations to attendees.
                CreateItemResponseType createResponse =
                      esb.CreateItem(createRequest);
    
                // Check the result.
                if (createResponse.ResponseMessages.Items[0].ResponseClass !=
                      ResponseClassType.Success)
                {
                    throw new Exception("EWSWrap.SendAppointment failed.");
                }
    
    Cheers
    Glen
  • Friday, November 06, 2009 10:17 PMDavid Claux - MSFT Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    As Glen indicates, the above code is written with the EWS Managed API. The EWS Managed API works just fine against an Exchange 2007 SP1 server. It makes coding against EWS way easier than with auto-generated proxies, and also makes applications much more maintainable (you can probably tell from the huge difference between the two samples Glen posted).

    I'd encourage you to try the EWS Managed API for yourself.

    You can download it here: http://www.microsoft.com/downloads/details.aspx?displaylang=en&FamilyID=e8f38dd1-f123-4a16-b4c8-584d1f84af48
    Documentation is here: http://msdn.microsoft.com/en-us/library/dd633710.aspx
    David Claux | Program Manager - Exchange Web Services
  • Monday, November 09, 2009 8:36 AMDanil Novhorodov Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    Thanks guys. EWS Managed API is really much easier to use. If I would have some extra time for my project I will make some refactoring from EWS proxy to Managed API. But I already had some kind of framework which wraps EWS proxy. :)