5

是否有关于如何使用 EWS for Exchange 2007 使用 C# 创建会议请求的工作示例?需要哪些属性?我添加了一个 Web 服务引用,可以连接以创建和发送各种项目,但不断收到错误“设置操作对属性无效”。关于响应消息。它从不说什么属性是无效的

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 ="test1@domain.com",RoutingType = "SMTP"}},
        new AttendeeType{Mailbox =new EmailAddressType{
                         EmailAddress ="test2@domain.com",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];

Microsoft 在http://msdn.microsoft.com/en-us/library/aa494190(EXCHG.140).aspx上提供了一个 XML 示例,说明消息项的外观。仅仅设置这些属性似乎是不够的。有人可以告诉我我缺少什么或指出一些更好的示例或文档吗?

<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>attendee0@example.com</t:EmailAddress>
          </t:Mailbox>
        </t:Attendee>
        <t:Attendee>
          <t:Mailbox>
            <t:EmailAddress>attendee1@example.com</t:EmailAddress>
          </t:Mailbox>
        </t:Attendee>
      </t:RequiredAttendees>
      <t:OptionalAttendees>
        <t:Attendee>
          <t:Mailbox>
            <t:EmailAddress>attendee2@example.com</t:EmailAddress>
          </t:Mailbox>
        </t:Attendee>
      </t:OptionalAttendees>
      <t:Resources>
        <t:Attendee>
          <t:Mailbox>
            <t:EmailAddress>room0@example.com</t:EmailAddress>
          </t:Mailbox>
        </t:Attendee>
      </t:Resources>
    </t:CalendarItem>
  </Items>
</CreateItem>
4

1 回答 1

3

这对你来说可能为时已晚,但对于其他尝试这个的人来说。

问题似乎在于提供 Is-Specified 参数。我删除了 IsMeetingSpecified 并且请求有效。这是修改后的 CalendarItemType。

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 ="test@test.com"
            }
        },
    }
};
于 2012-01-11T21:24:12.963 回答