EWS新建会议

var ews = new ExchangeServiceBinding {
    Credentials = new NetworkCredential("user", "pass"),
    Url = "https://servername/ews/exchange.asmx",
    RequestServerVersionValue = new RequestServerVersion {
        Version = ExchangeVersionType.Exchange2007}
};
var startDate = new DateTime(2010, 9, 18, 16, 00, 00);
var meeting = new CalendarItemType {
    IsMeeting = true,
    IsMeetingSpecified = true,
    Subject = "test EWS",
    Body = new BodyType {Value = "test body", BodyType1 = BodyTypeType.HTML},
    Start = startDate,
    StartSpecified = true,
    End = startDate.AddHours(1),
    EndSpecified = true,
    MeetingTimeZone = new TimeZoneType{
        TimeZoneName = TimeZone.CurrentTimeZone.StandardName, BaseOffset = "PT0H"},
    Location = "Meeting",
    RequiredAttendees = new [] {
        new AttendeeType{Mailbox =new EmailAddressType{
                         EmailAddress ="[email protected]",RoutingType = "SMTP"}},
        new AttendeeType{Mailbox =new EmailAddressType{
                         EmailAddress ="[email protected]",RoutingType = "SMTP"}}
    }
};
var request = new CreateItemType {
    SendMeetingInvitations =
        CalendarItemCreateOrDeleteOperationType.SendToAllAndSaveCopy,
    SendMeetingInvitationsSpecified = true,
    SavedItemFolderId = new TargetFolderIdType{Item = new DistinguishedFolderIdType{
                                        Id=DistinguishedFolderIdNameType.calendar}},
    Items = new NonEmptyArrayOfAllItemsType {Items = new ItemType[] {meeting}}
};
CreateItemResponseType response = ews.CreateItem(request);
var responseMessage = response.ResponseMessages.Items[0];
 
<CreateItem
       xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
       SendMeetingInvitations="SendToAllAndSaveCopy" >
  <SavedItemFolderId>
    <t:DistinguishedFolderId Id="calendar"/>
  </SavedItemFolderId>
  <Items>
    <t:CalendarItem>
      <t:Subject>Meeting with attendee0, attendee1, attendee2</t:Subject>
      <t:Body BodyType="Text">CalendarItem:TextBody</t:Body>
      <t:Start>2006-06-25T10:00:00Z</t:Start>
      <t:End>2006-06-25T11:00:00Z</t:End>
      <t:Location>CalendarItem:Location</t:Location>
      <t:RequiredAttendees>
        <t:Attendee>
          <t:Mailbox>
            <t:EmailAddress>[email protected]</t:EmailAddress>
          </t:Mailbox>
        </t:Attendee>
        <t:Attendee>
          <t:Mailbox>
            <t:EmailAddress>[email protected]</t:EmailAddress>
          </t:Mailbox>
        </t:Attendee>
      </t:RequiredAttendees>
      <t:OptionalAttendees>
        <t:Attendee>
          <t:Mailbox>
            <t:EmailAddress>[email protected]</t:EmailAddress>
          </t:Mailbox>
        </t:Attendee>
      </t:OptionalAttendees>
      <t:Resources>
        <t:Attendee>
          <t:Mailbox>
            <t:EmailAddress>[email protected]</t:EmailAddress>
          </t:Mailbox>
        </t:Attendee>
      </t:Resources>
    </t:CalendarItem>
  </Items>
</CreateItem>
 
var meeting = new CalendarItemType
{
    IsMeeting = true,
    Subject = "test EWS",
    Body = new BodyType { Value = "test body", BodyType1 = BodyTypeType.HTML },
    Start = startDate,
    StartSpecified = true,
    End = startDate.AddHours(1),
    EndSpecified = true,
    MeetingTimeZone = new TimeZoneType
    {
        TimeZoneName = TimeZone.CurrentTimeZone.StandardName,
        BaseOffset = "PT0H"
    },
    Location = "Room 1",
    RequiredAttendees = new[] {
        new AttendeeType
        {
            Mailbox =new EmailAddressType
            {    
                EmailAddress ="[email protected]"
            }
        },
    }
};

你可能感兴趣的:(新建)