Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1004108
  • 博文数量: 150
  • 博客积分: 3017
  • 博客等级: 少校
  • 技术积分: 3829
  • 用 户 组: 普通用户
  • 注册时间: 2011-11-19 14:40
个人简介

Now in Baidu WISE team

文章分类

全部博文(150)

文章存档

2014年(8)

2013年(31)

2012年(111)

分类: C#/.net

2013-06-03 16:03:41


以下的过程,使用的依然都是PROPPATCH和MOVE/COPY方法,具体构造以及调用过程,请参照之前的文章。

接受会议邀请

接受会议邀请是一个复杂的过程。对已一个受邀者来说,他接受到的是Inbox中的一份邀请的EML.要接受邀请,首先要在Calendar中,产生一个会议,同时,还要发出一份Accpeted的邮件。这是两个独立的过程。

1.查找到Inbox中对应指定会议的邮件,得到它的url。
  在之前的文章中,我们将一个文件移动到##DavMailSubmissionURI##中以发送会议邀请。那时的文件名,在接受者的Inbox中,并没有任何改变。所以可以直接得到它的url 当然,这个文件的名字就是我们最初创建这个会议时所取的。这是在我们知道eml的名字的条件下。如果我们不知道这个eml具体的文件名,就需要通过SEARCH的方法来获取。具体SEARCH的方法我没有使用,但是网上可以找到具体材料,请自行研究。
  同时,我们还要从中取出它的发送者,因为我们还要重写MailHeader里面的内容,换成正确的收件人。无论是接受还是拒绝,收件人都是这个会议邀请的发送者。

2.复制该EML到Calendar中

3.修改Calendar中的该会议使之变成Confirmed状态

  1. <?xml version="1.0" ?>
  2. <a:propertyupdate
  3.         xmlns:a="DAV:"
  4.         xmlns:e=""
  5.         xmlns:cal="urn:schemas:calendar:"
  6.         xmlns:mapi="" >
  7.     <a:set>
  8.         <a:prop>
  9.             <e:outlookmessageclass>IPM.Appointment</e:outlookmessageclass>
  10.             <a:contentclass>urn:content-classes:appointment</a:contentclass>
  11.             <cal:dtstamp>2007-08-22T16:14:30.492Z</cal:dtstamp>
  12.             <cal:meetingstatus>CONFIRMED</cal:meetingstatus>
  13.             <cal:method>REQUEST</cal:method>
  14.             <mapi:responsestatus>3</mapi:responsestatus>
  15.         </a:prop>
  16.     </a:set>
  17. </a:propertyupdate>


    
4.移动该EML到Drafts中


5.修改Drafts中的EML,然后移动到##DavMailSubmissionURI##中。
这里要注意mailheader中的from 结点。这个结点的值,如果不改为当前用户的话,那么虽然接受邮件是当前用户发出的,也就是sender是当前用户,但是from值仍然为原来的的会议的组织者。那么发出的邮件,并不是当前用户接受会议邀请,而是当期用户,代表会议组织者,接受会议,接受会议的是组织者。即是当前用户 be half on 组织者accept。

  1. <?xml version="1.0" ?>
  2. <a:propertyupdate
  3.         xmlns:a="DAV:"
  4.         xmlns:e=""
  5.         xmlns:cal="urn:schemas:calendar:"
  6.         xmlns:mapi="urn:schemas:httpmail:"
  7.         xmlns:mailheader="urn:schemas:mailheader:"
  8.         xmlns:mapi="" >
  9.     <a:set>
  10.         <a:prop>
  11.             <e:outlookmessageclass>IPM.Schedule.Meeting.Resp.Pos</e:outlookmessageclass>
  12.             <a:contentclass>urn:content-classes:calendarmessage</a:contentclass>
  13.             <cal:dtstamp>2007-08-22T16:18:07.532Z</cal:dtstamp>
  14.             <cal:meetingstatus>CONFIRMED</cal:meetingstatus>
  15.             <cal:method>REPLY</cal:method>
  16.             <mapi:subject>Accepted: yourOriginalSubjectHere</mapi:subject>
  17.             <mailheader:to>to_Email@this_is_the_from_property_value_of_the_received_meeting_request</mailheader:to>
  18.             whoacceptmeeting@this_is_the_from_property_value_of_the_received_meeting_request
  19.             <mapi:responsestatus>3</mapi:responsestatus>
  20.         </a:prop>
  21.     </a:set>
  22. </a:propertyupdate>




6.对于以上2个PROPPATCH的方法,我们都打了时间戳,其格式是:

  1. public static String ConvertToTimeStamp(DateTime dt)
  2.         {
  3.             return dt.ToString("yyy-MM-ddThh:mm:ss.fffZ");
  4.         }



拒绝会议邀请:
相比接受,我们只需要将邀请eml修改之后发送即可,无需其他操作。
1.查找到Inbox中对应指定会议的邮件,得到它的url
2.移动该EML到Drafts中
3.修改Drafts中的EML,然后移动到##DavMailSubmissionURI##中。


  1. <?xml version="1.0" ?>
  2. <a:propertyupdate
  3.         xmlns:a="DAV:"
  4.         xmlns:e=""
  5.         xmlns:cal="urn:schemas:calendar:"
  6.         xmlns:mapi="urn:schemas:httpmail:"
  7.         xmlns:mailheader="urn:schemas:mailheader:"
  8.         xmlns:mapi="" >
  9.     <a:set>
  10.         <a:prop>
  11.             <e:outlookmessageclass>IPM.Schedule.Meeting.Resp.Neg</e:outlookmessageclass>
  12.             <a:contentclass>urn:content-classes:calendarmessage</a:contentclass>
  13.             <cal:dtstamp>2007-08-22T15:36:52.696Z</cal:dtstamp>
  14.             <cal:method>REPLY</cal:method>
  15.             <header:to>to_Email@this_is_the_from_property_value_of_the_received_meeting_request</header:to>
  16.             <mailheader:from>whoacceptmeeting@this_is_the_from_property_value_of_the_received_meeting_request</mailheader:from>
  17.            <mapi:responsestatus>3</mapi:responsestatus>
  18.         </a:prop>
  19.     </a:set>
  20. </a:propertyupdate>



循环会议
循环会议本质上和单独的会议是一样,只是增加了一些额外的结点,以描述这部分信息。
主要的就是
描述了循环类型。 (好像不要也可以)
最重要的结点,描述了循环的细节。
时区信息, 必须要有。
循环结束时间。


  1. <?xml version="1.0"?>

  2. <propertyupdate xmlns="DAV:"

  3. xmlns:c="urn:schemas:calendar:"

  4. xmlns:x="xml:"

  5. xmlns:ma=""

  6. xmlns:e="">

  7.    <set>

  8.       <prop>

  9.         <ma:recurtype>2</ma:recurtype>

  10.         <c:instancetype>1</c:instancetype>

  11.         <c:rrule>

  12.           <x:v>FREQ=WEEKLY;WKST=SU;INTERVAL=1;BYDAY=TH</x:v>

  13.         </c:rrule>

  14.         <c:timezoneid>10</c:timezoneid>

  15.         <e:patternend>9999-12-31T05:00:00.000Z</e:patternend>

  16.        </>

  17.    </>

  18. </>



这部分内容描述起来颇为麻烦,因为情况太多。如需了解细节,可以尝试自己建立不同的类型的会议,然后使用第一篇文章中提到的Exchange Explorer具体查看每个结点的值。
直接给出使用的代码。该代码部分实现了一些循环会议的定义。


  1. public class Recurrence
  2.     {
  3.         private static String WeekDayToString(DayOfWeek day)
  4.         {

  5.             switch (day)
  6.             {
  7.                 case DayOfWeek.Monday:
  8.                     return "MO";
  9.                 case DayOfWeek.Tuesday:
  10.                     return "TU";
  11.                 case DayOfWeek.Wednesday:
  12.                     return "WE";
  13.                 case DayOfWeek.Thursday:
  14.                     return "TH";
  15.                 case DayOfWeek.Friday:
  16.                     return "FR";
  17.                 case DayOfWeek.Saturday:
  18.                     return "SA";
  19.                 case DayOfWeek.Sunday:
  20.                     return "SU";
  21.             }
  22.             return string.Empty;
  23.         }

  24.         private static String FreqToString(FreqEnum fr)
  25.         {
  26.             switch (fr)
  27.             {
  28.                 case FreqEnum.Daily:
  29.                     return "DAILY";
  30.                 case FreqEnum.Weekly:
  31.                     return "WEEKLY";
  32.                 case FreqEnum.Monthly:
  33.                     return "MONTHLY";

  34.             }
  35.             return string.Empty;
  36.         }
  37.         public DayOfWeek WeekDay;
  38.         public FreqEnum Freq;
  39.         public int Interval;
  40.         public DateTime EndDate;
  41.         public int MonthDay;

  42.         private bool IsReady = false;

  43.         public void SetWeeklyReccur(DayOfWeek dw, int interval, DateTime endDate)
  44.         {
  45.             this.Freq = FreqEnum.Weekly;
  46.             this.IsReady = true;
  47.             this.WeekDay = dw;
  48.             this.Interval = interval;
  49.             this.EndDate = endDate;
  50.         }
  51.         public void SetMonthlyReccur(int dm, int interval, DateTime endDate)
  52.         {
  53.             this.Freq = FreqEnum.Monthly;
  54.             this.IsReady = true;
  55.             this.MonthDay = dm;
  56.             this.Interval = interval;
  57.             this.EndDate = endDate;
  58.         }

  59.         public void SetDailyReccur(int interval, DateTime endDate)
  60.         {
  61.             this.Freq = FreqEnum.Daily;
  62.             this.IsReady = true;
  63.             this.IsReady = true;
  64.             this.Interval = interval;
  65.             this.EndDate = endDate;
  66.         }


  67.         //FREQ=WEEKLY;WKST=FR;INTERVAL=1;BYDAY=TH"
  68.         public String ToPatch()
  69.         {
  70.             if (!this.IsReady)
  71.                 return string.Empty;
  72.             String freqstr = "FREQ=" + FreqToString(this.Freq);
  73.             String wkstr = "WKST=SU";
  74.             String intervalstr = "INTERVAL=" + this.Interval.ToString();
  75.             String bydaystr = "BYDAY=";
  76.             String recurtype = string.Empty;
  77.             switch (this.Freq)
  78.             {
  79.                 case FreqEnum.Monthly:
  80.                     recurtype = "3";
  81.                     bydaystr += this.MonthDay.ToString();
  82.                     break;
  83.                 case FreqEnum.Weekly:
  84.                     recurtype = "2";
  85.                     bydaystr += WeekDayToString(this.WeekDay);
  86.                     break;
  87.                 case FreqEnum.Daily:
  88.                     recurtype = "1";
  89.                     bydaystr = string.Empty;
  90.                     break;
  91.                 default:
  92.                     break;
  93.             }
  94.             StringBuilder sb = new StringBuilder();
  95.             sb.Append(freqstr);
  96.             sb.Append(";");
  97.             sb.Append(wkstr);
  98.             sb.Append(";");
  99.             sb.Append(intervalstr);
  100.             sb.Append(";");
  101.             sb.Append(bydaystr);


  102.             string ret = "" + recurtype + ""
  103.                 + "1"
  104.              + ""
  105.              + "" + sb.ToString() + ""
  106.             + ""
  107.             + "8"
  108.             + "" + StaticLib.ConvertToTimeStamp(this.EndDate) + "";
  109.             return ret;


  110.         }

  111.     }

Reference:
http://weblogs.sqlteam.com/mladenp/archive/2007/08/22/Exchange-Accept-and-Cancel-Meeting-Request-with-WebDav.aspx

http://blogs.msdn.com/b/mstehle/archive/2006/03/10/547991.aspx


阅读(3056) | 评论(2) | 转发(0) |
给主人留下些什么吧!~~