Exchange Web 服务创建会议请求工作示例

发布于 2024-09-24 10:02:13 字数 4453 浏览 1 评论 0原文

是否有关于如何使用 C# 使用 EWS for Exchange 2007 创建会议请求的工作示例?需要哪些属性?我添加了一个 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 ="[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];

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

<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>

Is there a working example anywhere of how to create a meeting request using EWS for Exchange 2007 using C#? Which properties are required? I have added a web service reference and can connect to create and send various items but keep getting the error "Set action is invalid for property." on the response messages. It never says what property is invalid

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];

Microsoft provides an XML example at http://msdn.microsoft.com/en-us/library/aa494190(EXCHG.140).aspx of what the message item should look like. Just setting these properties does not seem to be enough. Can someone tell me what I'm missing or point me to some better examples or documentation?

<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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

云裳 2024-10-01 10:02:13

这对你来说可能为时已晚,但对其他尝试此操作的人来说却太晚了。

问题似乎在于提供 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 ="[email protected]"
            }
        },
    }
};

This is probably too late for you, but this for anyone else trying this.

The issue seems to be with providing the Is-Specified params. I deleted the IsMeetingSpecified and the request worked. Here's the revised 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 ="[email protected]"
            }
        },
    }
};
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文