http://www.infini-tec.de/InfiniTec - Henning Krauses Blog - Exchange library2010-11-27T05:04:48+00:00Don't adjust your mind - it's reality that is malfunctioning Henning KrauseBlogEngine.Net Syndication Generatorhttp://www.infini-tec.de/opml.axdHenning KrauseDon't adjust your mind - it's reality that is malfunctioning en-USInfiniTec - Henning Krauses Blog 0.0000000.000000http://www.infini-tec.de/post/2008/12/30/Simple-push-notification-client.aspxSimple push notification client2008-12-30T21:55:11+00:00hkrause<p>As I wrote in my <a href="http://www.infinitec.de/post/2008/12/30/Exchange-2007-Push-notifications-made-easy.aspx">earlier post</a>, I recently published a component on CodePlex that simplifies using push notifications in your applications. Since I’ve not published a full fledged sample application, I will start with a series of blog posts. I will tag all related articles on this topic with “push notifications”, and you can get a list of all articles with this link: <a href="http://www.infinitec.de/?tag=/push+notifications">http://www.infinitec.de/?tag=/push+notifications</a>.</p> <p>I’ll start with a very simple application: A console application that creates one subscription get notifications about new mails arriving in the mailbox of the current user.</p> <div> <div style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"> <pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 1:</span> <span style="color: #0000ff">using</span> System;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 2:</span> <span style="color: #0000ff">using</span> System.Net;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 3:</span> <span style="color: #0000ff">using</span> InfiniTec.Exchange.Notifications;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 4:</span>  </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 5:</span> <span style="color: #0000ff">namespace</span> ExchangeNotificationTestClient</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 6:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 7:</span> <span style="color: #0000ff">internal</span> <span style="color: #0000ff">class</span> Program</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 8:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 9:</span> <span style="color: #0000ff">private</span> <span style="color: #0000ff">static</span> <span style="color: #0000ff">void</span> Main()</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 10:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 11:</span> <span style="color: #008000">// Ignore any certificate errors</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 12:</span> ServicePointManager.ServerCertificateValidationCallback += </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 13:</span> (sender, certificate, chain, sslPolicyErrors) => <span style="color: #0000ff">true</span>;</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 14:</span>  </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 15:</span> <span style="color: #008000">// Setup the adapter which will be used to call into the Exchange WebService</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 16:</span> var adapter = <span style="color: #0000ff">new</span> ExchangeWebServicesAdapter(</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 17:</span> <span style="color: #0000ff">new</span> Uri(<span style="color: #006080">"https://casserver/ews/exchange.asmx"</span>), </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 18:</span> <span style="color: #0000ff">new</span> NetworkCredential(<span style="color: #006080">"administrator"</span>, <span style="color: #006080">"password"</span>, <span style="color: #006080">"contoso"</span>));</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 19:</span>  </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 20:</span> <span style="color: #008000">// Create a new subscription collection to manage all the subscriptions</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 21:</span> var subscriptionCollection = <span style="color: #0000ff">new</span> SubscriptionCollection(adapter);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 22:</span>  </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 23:</span> <span style="color: #008000">// Setup a listener that listens on port 80 on the local computer</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 24:</span> <span style="color: #0000ff">using</span> (var listener = <span style="color: #0000ff">new</span> PushNotificationListener())</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 25:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 26:</span> <span style="color: #008000">// Register for a NewMail notification on the inbox of the administrator</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 27:</span> subscriptionCollection.Add(</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 28:</span> <span style="color: #0000ff">new</span>[] {<span style="color: #0000ff">new</span> FolderReference(WellKnownFolderId.Inbox)}, </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 29:</span> EventTypes.NewMail);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 30:</span> Console.Out.WriteLine(<span style="color: #006080">"Starting Notification Service..."</span>);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 31:</span> listener.Start();</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 32:</span>  </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 33:</span> Console.Out.WriteLine(<span style="color: #006080">"Creating subscription"</span>);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 34:</span>  </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 35:</span> <span style="color: #0000ff">foreach</span> (var subscription <span style="color: #0000ff">in</span> subscriptionCollection)</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 36:</span> {</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 37:</span> <span style="color: #008000">// Write a line to the console for each new mail received</span></pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 38:</span> subscription.NewMail += (sender, e) => </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 39:</span> Console.Out.WriteLine(<span style="color: #0000ff">string</span>.Format(<span style="color: #006080">"{0}: New Mail arrived in your inbox"</span>, e.Timestamp));</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 40:</span> subscription.Start(listener);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 41:</span> }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 42:</span>  </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 43:</span> Console.Out.WriteLine(<span style="color: #006080">"Waiting for notifications... Hit [Enter] to quit..."</span>);</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 44:</span>  </pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 45:</span> Console.ReadLine();</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 46:</span> }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 47:</span> }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 48:</span> }</pre>
<pre style="border-bottom-style: none; padding-bottom: 0px; line-height: 12pt; border-right-style: none; background-color: #f4f4f4; margin: 0em; padding-left: 0px; width: 100%; padding-right: 0px; font-family: consolas, 'Courier New', courier, monospace; border-top-style: none; color: black; font-size: 8pt; border-left-style: none; overflow: visible; padding-top: 0px"><span style="color: #606060"> 49:</span> }</pre>
</div>
</div>
<p>There are four important classes used in this example:</p>
<ol>
<li>The <strong>ExchangeServiceAdapter</strong> (created in line 16) is used to actually perform the Web Services calls to the Exchange Server (CAS Role). It’s a rather simple implementation, as it does not support AutoDiscover. You have to specify the Exchange server manually. It does, however, support Exchange Impersonation. And if you want to subscribe to events on public folders, you’ll have to enable this feature by setting the ExchangeServiceAdapter.IsPublicFolderAccessEnabled to true. Your Exchange Server must have Service Pack 1 installed to use this feature. </li>
<li>The <strong>PushNotificationListener</strong> (created in line 24): This class does all the necessary WCF plumbing to setup a host, receives the notifications and channels them to the right subscription. </li>
<li>The <strong>SubscriptionCollection</strong>: (created in line 21) It’s not really necessary, but it makes is more easy to handle multiple subscriptions. </li>
<li>The <strong>Subscription</strong> (created in line 27). You can either create a subscription by calling SubscriptionCollection.Add(), or create a subscription directly via “new Subscription()”. </li>
</ol>
<p>Both, the PushNotificationListener and the Subscription need to be started to do some actual work. And that’s all you need to do to get a simple notification client up and running. However, there are some security settings to consider, because WCF doesn’t let you run around and open endpoints on your users machines. Additionally, the Windows Firewall needs to be configured correctly to let the notifications through. I’ll discuss this in a separate post.</p>2008-12-30T21:55:11+00:00hkrausehttp://www.infini-tec.de/pingback.axdhttp://www.infini-tec.de/post.aspx?id=b332b17e-9f14-4984-82c9-f644b2cc79d75http://www.infini-tec.de/trackback.axd?id=b332b17e-9f14-4984-82c9-f644b2cc79d7http://www.infini-tec.de/post/2008/12/30/Simple-push-notification-client.aspx#commenthttp://www.infini-tec.de/syndication.axd?post=b332b17e-9f14-4984-82c9-f644b2cc79d7http://www.infini-tec.de/post/2007/04/09/InfiniTecExchange-0994-released.aspxInfiniTec.Exchange 0.99.4 released2007-04-08T22:00:00+00:00hkrause<div xmlns="http://www.w3.org/1999/xhtml"><p>This release brings a bunch of bugfixes and some new features: The Subscription and SubscriptionCollection classes implement the WebDAV push event feature: Now you can subscribe to changes made to folders and elements. Here's a diagram of the system:</p><p><a href=file.axd?file=infinitec_exchange_0_99_4/91503fbae474870.jpg style="margin-right: 10px; display: block;"><img src=file.axd?file=infinitec_exchange_0_99_4/preview_91503fbae474870.jpg title="Class diagram of the Subscription management" float="false" style=";border: none;" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" /><br /><span style="font-size: 8pt;font-style: italic;text-align: right;clear: left;">Class diagram of the Subscription management (click to enlarge)</span></a></p><p>Access to the SubscriptionCollection is exposed via the Connection Class, although you are free to create your own instance. By default, it binds to a local port between 1024 and 5000, but you can specify a fixed port also. An example is not yed available.</p><p>Another cool new feature is the incorporation of my little Expression classes. These classes allow you to easily build expressions for filter items in a ItemCollection or Searcher class. A typical example would be to filter all appointments in a folder between a specified date range. You can do this now very easily:</p><div class="clsCode" style="FONT-SIZE: 10pt; BACKGROUND-COLOR: #f0f0f0"><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 1</span> <span style="color: #2b91af;">Expression</span> expression = <span style="color: #2b91af;">Expression</span>.And(<span style="color: #2b91af;">Expression</span>.Equals(<span style="color: #2b91af;">WellknownProperties</span>.<span style="color: #2b91af;">Appointment</span>.Starttime, <span style="color: #2b91af;">DateTime</span>.Now),</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 2</span> <span style="color: #2b91af;">Expression</span>.Equals(<span style="color: #2b91af;">WellknownProperties</span>.<span style="color: #2b91af;">Appointment</span>.EndTime, <span style="color: #2b91af;">DateTime</span>.Now.AddDays(3)));</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 3</span> </span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 4</span> <span style="color: #0000ff;">using</span> (<span style="color: #2b91af;">Connection</span> connection = <span style="color: #0000ff;">new</span><span style="color: #2b91af;">Connection</span>(server, <span style="color: #2b91af;">ConnectionProtocol</span>.Default, <span style="color: #0000ff;">new</span><span style="color: #2b91af;">Credential</span>(<span style="color: #a31515;">username</span>, <span style="color: #a31515;">password</span>, <span style="color: #2b91af;">AuthenticationType</span>.Ntlm)))</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 5</span> {</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 6</span> <span style="color: #2b91af;">Mailbox</span> mbx = <span style="color: #0000ff;">new</span><span style="color: #2b91af;">Mailbox</span>(<span style="color: #a31515;">"exchange/administrator"</span>, connection);</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 7</span> mbx.Refresh();</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 8</span> </span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 9</span> mbx.Calendar.Items.ConstraintExpression += expression;</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 10</span> mbx.Calendar.Items.Refresh();</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 11</span> </span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 12</span> <span style="color: #0000ff;">foreach</span> (<span style="color: #2b91af;">CalendarItem</span> item <span style="color: #0000ff;">in</span> mbx.Calendar.Items)</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 13</span> {</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 14</span> ProcessItem(item);</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 15</span> }</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 16</span> }</span></p></div><p>One special thing about this: You can concatenate two expressions by using the plus operator. This will result in both expressions being ANDed.</p><p>No more worrying about casting properties to the right type and such. You don't even have to worry about time zones - all handled automagically.</p><p>Here is a small overview over the expression classes:</p><p><a href=file.axd?file=infinitec_exchange_0_99_4/7bd87ef482524509.jpg style="margin-right: 10px; display: block;"><img src=file.axd?file=infinitec_exchange_0_99_4/preview_7bd87ef482524509.jpg title="Class diagram for the expression classes" float="false" style=";border: none;" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" /><br /><span style="font-size: 8pt;font-style: italic;text-align: right;clear: left;">Class diagram for the expression classes (click to enlarge)</span></a></p><h3>Changelog</h3><div><ul style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" type="disc"><li>Fixed a bug in the FolderCollection class</li><li>Fixed a bug in the TaskItem.PreSave() method which caused the Content class of the item not to be set.</li><li>Fixed a bug in the TaskItem.PreSave() method which prevented a successful modification of the TaskStatus (Would not work if PercentComplete was not set)</li><li>The Searcher<ItemType> now get the correct set of properties for the specific item types.</li><li>Changed the type of TaskItem.PercentComplete from float to double</li><li>Exchange 'float' datatype is now handled as 'System.Double' instead of 'System.Float'</li><li>New method ApplyInheritedSecurity(FolderSecurity): Clears all security descriptor entries and applies the security settings from the specified descriptor. (Experimental!)</li><li>SchemaClass attribute is now public</li><li>The ItemCollection and ItemCollection<ItemType> classes now expose a IList<string> PropertiesToLoad property</li><li>Renamed ChildItems and ChildFolders of the Folder and Folder<ItemType> classes to Items and Folders.</li><li>Moved the IsRead property from MessageItem to Item</li><li>Made the IsRead property writable</li><li>Fixed a bug in the Property class which prevented setting propertyvalues to 0 or false</li><li>Replaced the HttpStatus class with a PropertyStatus enumeration. HttpStatus was used with the Property.Status property.</li><li>Added support for InfiniTec.Expressions on the Searcher, Item- and FolderCollections. Constraints can now be either specified using the Constraints property or the ConstraintExpression property.</li><li>SubscriptionCollection and Subscription implement WebDAV events</li></ul></div></div><h2 xmlns="http://www.w3.org/1999/xhtml">Downloads</h2><table xmlns="http://www.w3.org/1999/xhtml"><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec_exchange_0_99_4/zip.gif /></td><td><a href=file.axd?file=infinitec_exchange_0_99_4/ReleaseBuild.zip>ReleaseBuild.zip</a> (497,091 Bytes)<br />Optimized build with a strong name and AuthentiCode signature</td></tr><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec_exchange_0_99_4/zip.gif /></td><td><a href=file.axd?file=infinitec_exchange_0_99_4/SourceAndDemoApplication.zip>SourceAndDemoApplication.zip</a> (496,678 Bytes)<br />The source files and the demo application</td></tr><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec_exchange_0_99_4/zip.gif /></td><td><a href=file.axd?file=infinitec_exchange_0_99_4/Documentation.zip>Documentation.zip</a> (2,087,722 Bytes)<br />The documentation as CHM file</td></tr></table>2007-04-08T22:00:00+00:00hkrauseThis release brings a bunch of bugfixes and some new features: The Subscription and SubscriptionCollection classes implement the WebDAV push event feature: Now you can subscribe to changes made to folders and elements. Here's a diagram of the system:Access to the SubscriptionCollection is exposed via the Connection Class, although you are free to create your own instance. By default, it binds to a local port between 1024 and 5000, but you can specify a fixed port also. An example is not yed available.Another cool new feature is the incorporation of my little Expression classes. These classes allow you to easily build expressions for filter items in a ItemCollection or Searcher class. A typical example would be to filter all appointments in a folder between a specified date range. You can do this now very easily: 1 Expression expression = Expression.And(Expression.Equals(WellknownProperties.Appointment.Starttime, DateTime.Now), 2 Expression.Equals(WellknownProperties.Appointment.EndTime, DateTime.Now.AddDays(3))); 3 4 using (Connection connection = newConnection(server, ConnectionProtocol.Default, newCredential(username, password, AuthenticationType.Ntlm))) 5 { 6 Mailbox mbx = newMailbox("exchange/administrator", connection); 7 mbx.Refresh(); 8 9 mbx.Calendar.Items.ConstraintExpression += expression; 10 mbx.Calendar.Items.Refresh(); 11 12 foreach (CalendarItem item in mbx.Calendar.Items) 13 { 14 ProcessItem(item); 15 } 16 }One special thing about this: You can concatenate two expressions by using the plus operator. This will result in both expressions being ANDed.No more worrying about casting properties to the right type and such. You don't even have to worry about time zones - all handled automagically.Here is a small overview over the expression classes:Fixed a bug in the FolderCollection classFixed a bug in the TaskItem.PreSave() method which caused the Content class of the item not to be set.Fixed a bug in the TaskItem.PreSave() method which prevented a successful modification of the TaskStatus (Would not work if PercentComplete was not set)The Searcher<ItemType> now get the correct set of properties for the specific item types.Changed the type of TaskItem.PercentComplete from float to doubleExchange 'float' datatype is now handled as 'System.Double' instead of 'System.Float'New method ApplyInheritedSecurity(FolderSecurity): Clears all security descriptor entries and applies the security settings from the specified descriptor. (Experimental!)SchemaClass attribute is now publicThe ItemCollection and ItemCollection<ItemType> classes now expose a IList<string> PropertiesToLoad propertyRenamed ChildItems and ChildFolders of the Folder and Folder<ItemType> classes to Items and Folders.Moved the IsRead property from MessageItem to ItemMade the IsRead property writableFixed a bug in the Property class which prevented setting propertyvalues to 0 or falseReplaced the HttpStatus class with a PropertyStatus enumeration. HttpStatus was used with the Property.Status property.Added support for InfiniTec.Expressions on the Searcher, Item- and FolderCollections. Constraints can now be either specified using the Constraints property or the ConstraintExpression property.SubscriptionCollection and Subscription implement WebDAV eventshttp://www.infini-tec.de/pingback.axdhttp://www.infini-tec.de/post.aspx?id=a1c07dcf-e817-4a69-99c0-e5eecfcac7125http://www.infini-tec.de/trackback.axd?id=a1c07dcf-e817-4a69-99c0-e5eecfcac712http://www.infini-tec.de/post/2007/04/09/InfiniTecExchange-0994-released.aspx#commenthttp://www.infini-tec.de/syndication.axd?post=a1c07dcf-e817-4a69-99c0-e5eecfcac712http://www.infini-tec.de/post/2007/02/15/Exchange-library-updated.aspxExchange library updated2007-02-14T23:00:00+00:00hkrause<div xmlns="http://www.w3.org/1999/xhtml">Another maintenance update with a bunch of bugfixes...<h3>Changelog</h3><div><ul style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" type="disc"><li>Fixed bugs in the ItemCollection.Add, ItemCollection<T>.Add and FolderCollection.Add method</li><li>Fixed NullReferenceException bugs in the ItemBase constructors</li><li>New Interface IKeyedCollection </li><li>Contact EmailAddresses and PhysicalAddresses are now of type IKeyedCollection</li><li>The Item Class and all its descendents now have an Url property (delegated from BaseItem</li><li>Fixed a bug in the ContactItem class regarding the population of the PhysicalAddress list</li><li>Fixes a bug in the search method, which occured when the number of items in the search query where an exact multiple of the pagesize</li><li>New class SearchResult, which is used in the Methods.Search method. It contains the result items of the search, as well as the total number of items of the search.</li></ul></div></div><h2 xmlns="http://www.w3.org/1999/xhtml">Downloads</h2><table xmlns="http://www.w3.org/1999/xhtml"><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec_exchange_0_99_3/zip.gif /></td><td><a href=file.axd?file=infinitec_exchange_0_99_3/InfiniTec.Exchange_Release.zip>InfiniTec.Exchange_Release.zip</a> (453,287 Bytes)<br />Binaries (Release build with debug symbols) with a strong-name</td></tr><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec_exchange_0_99_3/zip.gif /></td><td><a href=file.axd?file=infinitec_exchange_0_99_3/InfiniTec.Exchange.zip>InfiniTec.Exchange.zip</a> (1,725,519 Bytes)<br />Source, Documentation and Example application</td></tr></table>2007-02-14T23:00:00+00:00hkrauseAnother maintenance update with a bunch of bugfixes...Fixed bugs in the ItemCollection.Add, ItemCollection<T>.Add and FolderCollection.Add methodFixed NullReferenceException bugs in the ItemBase constructorsNew Interface IKeyedCollection Contact EmailAddresses and PhysicalAddresses are now of type IKeyedCollectionThe Item Class and all its descendents now have an Url property (delegated from BaseItemFixed a bug in the ContactItem class regarding the population of the PhysicalAddress listFixes a bug in the search method, which occured when the number of items in the search query where an exact multiple of the pagesizeNew class SearchResult, which is used in the Methods.Search method. It contains the result items of the search, as well as the total number of items of the search.http://www.infini-tec.de/pingback.axdhttp://www.infini-tec.de/post.aspx?id=c0efad66-03b7-41a5-acd3-312774bd17230http://www.infini-tec.de/trackback.axd?id=c0efad66-03b7-41a5-acd3-312774bd1723http://www.infini-tec.de/post/2007/02/15/Exchange-library-updated.aspx#commenthttp://www.infini-tec.de/syndication.axd?post=c0efad66-03b7-41a5-acd3-312774bd1723http://www.infini-tec.de/post/2007/02/11/Enumerating-attachments-in-a-users-inbox-folder.aspxEnumerating attachments in a users inbox folder2007-02-10T23:00:00+00:00hkrause<div xmlns="http://www.w3.org/1999/xhtml"><p>One reader recently asked how he could use my InfiniTec.Exchange library to scan the mails in the inbox folder of a users mailbox for attachments. Here is an example:</p><div class="clsCode" style="FONT-SIZE: 10pt; BACKGROUND-COLOR: #f0f0f0"><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 1</span> <span style="color: #0000ff;">class</span><span style="color: #2b91af;">Program</span></span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 2</span> {</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 3</span> <span style="color: #0000ff;">static</span><span style="color: #0000ff;">void</span> Main(<span style="color: #0000ff;">string</span>[] args)</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 4</span> {</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 5</span> <span style="color: #2b91af;">ServicePointManager</span>.ServerCertificateValidationCallback = <span style="color: #0000ff;">delegate</span> { <span style="color: #0000ff;">return</span><span style="color: #0000ff;">true</span>; };</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 6</span> </span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 7</span> <span style="color: #0000ff;">using</span> (<span style="color: #2b91af;">Connection</span> connection = <span style="color: #0000ff;">new</span><span style="color: #2b91af;">Connection</span>(<span style="color: #a31515;">"server"</span>, <span style="color: #2b91af;">ConnectionProtocol</span>.Secure, <span style="color: #0000ff;">new</span><span style="color: #2b91af;">Credential</span>(<span style="color: #a31515;">"username"</span>, <span style="color: #a31515;">"password"</span>, <span style="color: #2b91af;">AuthenticationType</span>.Ntlm)))</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 8</span> {</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 9</span> <span style="color: #2b91af;">Mailbox</span> mbx;</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 10</span> </span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 11</span> <span style="color: #2b91af;">Console</span>.Out.WriteLine(<span style="color: #a31515;">"Refreshing mailbox...."</span>);</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 12</span> mbx = <span style="color: #0000ff;">new</span><span style="color: #2b91af;">Mailbox</span>(<span style="color: #a31515;">"exchange/useralias"</span>, connection);</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 13</span> mbx.Refresh();</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 14</span> </span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 15</span> <span style="color: #2b91af;">ItemCollection</span><<span style="color: #2b91af;">MessageItem</span>> children = mbx.Inbox.ChildItems;</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 16</span> </span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 17</span> children.Constraints +=</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 18</span> <span style="color: #0000ff;">string</span>.Format(<span style="color: #a31515;">"AND Cast(\"{0}\" as \"boolean\") = true"</span>, <span style="color: #2b91af;">WellknownProperties</span>.<span style="color: #2b91af;">Item</span>.HasAttachments);</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 19</span> </span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 20</span> <span style="color: #2b91af;">Console</span>.Out.WriteLine(<span style="color: #a31515;">"Enumerating child items with attachments in inbox..."</span>);</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 21</span> </span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 22</span> children.Refresh();</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 23</span> </span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 24</span> <span style="color: #2b91af;">Console</span>.Out.WriteLine(<span style="color: #a31515;">"Found {0} items"</span>, children.Count);</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 25</span> </span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 26</span> <span style="color: #0000ff;">foreach</span> (<span style="color: #2b91af;">MessageItem</span> item <span style="color: #0000ff;">in</span> children)</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 27</span> {</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 28</span> <span style="color: #2b91af;">Console</span>.Out.WriteLine(<span style="color: #a31515;">"Processing "</span> + item.Subject);</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 29</span> item.Attachments.Refresh();</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 30</span> </span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 31</span> <span style="color: #0000ff;">foreach</span> (<span style="color: #2b91af;">Attachment</span> attachment <span style="color: #0000ff;">in</span> item.Attachments)</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 32</span> {</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 33</span> <span style="color: #2b91af;">Console</span>.Out.WriteLine(<span style="color: #a31515;">"\t{0} ({1}, {2}, {3} bytes)"</span>, attachment.Name, attachment.MimeType, attachment.ContentDisposition, attachment.Size);</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 34</span> }</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 35</span> }</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 36</span> </span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 37</span> <span style="color: #2b91af;">Console</span>.Out.WriteLine(<span style="color: #a31515;">"Finished"</span>);</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 38</span> <span style="color: #2b91af;">Console</span>.ReadLine();</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 39</span> }</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 40</span> }</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 41</span> }</span></p></div><p>This is a console application, so you'll just have to replace the main class of a newly created console application with this code. Then, add a reference to my library (At least version 0.99.2).</p><p>The most tricky part here clearly is the modification of the constraints in line 17; The default constraint is initialized with this value:</p><div class="clsCode" style="FONT-SIZE: 10pt; BACKGROUND-COLOR: #f0f0f0"><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 1</span> _Searcher.Constraints = <span style="color: #0000ff;">string</span>.Format(<span style="color: #2b91af;">CultureInfo</span>.InvariantCulture, <span style="color: #a31515;">"(\"{0}\" = false) "</span>, <span style="color: #2b91af;">WellknownProperties</span>.<span style="color: #2b91af;">Dav</span>.IsFolder);</span></p></div><p>This restricts the result set to child elements which are not folders. To restrict the result set further, you can just append additional constraints with an "AND". The full constraint being used here is this:</p><div class="clsCode" style="FONT-SIZE: 10pt; BACKGROUND-COLOR: #f0f0f0"><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 1</span> ("DAV:isfolder" = false) AND Cast("http://schemas.microsoft.com/mapi/proptag/xe1b000b" as "boolean") = true</span></p></div><p>You'll probably wonder why I used the MAPI property <strong>0xe1b00b </strong>instead of the <strong>urn:schemas:httpmail:hasattachment </strong>property. In the past, I've found the latter property not very reliable - it was false, even though a message had an attachment. And since I'm using a non-standard property here, I have to cast it to boolean to make the request work. If you don't do this, you'll end up with a Bad Request error from exchange.</p></div>2007-02-10T23:00:00+00:00hkrauseOne reader recently asked how he could use my InfiniTec.Exchange library to scan the mails in the inbox folder of a users mailbox for attachments. Here is an example: 1 classProgram 2 { 3 staticvoid Main(string[] args) 4 { 5 ServicePointManager.ServerCertificateValidationCallback = delegate { returntrue; }; 6 7 using (Connection connection = newConnection("server", ConnectionProtocol.Secure, newCredential("username", "password", AuthenticationType.Ntlm))) 8 { 9 Mailbox mbx; 10 11 Console.Out.WriteLine("Refreshing mailbox...."); 12 mbx = newMailbox("exchange/useralias", connection); 13 mbx.Refresh(); 14 15 ItemCollection<MessageItem> children = mbx.Inbox.ChildItems; 16 17 children.Constraints += 18 string.Format("AND Cast(\"{0}\" as \"boolean\") = true", WellknownProperties.Item.HasAttachments); 19 20 Console.Out.WriteLine("Enumerating child items with attachments in inbox..."); 21 22 children.Refresh(); 23 24 Console.Out.WriteLine("Found {0} items", children.Count); 25 26 foreach (MessageItem item in children) 27 { 28 Console.Out.WriteLine("Processing " + item.Subject); 29 item.Attachments.Refresh(); 30 31 foreach (Attachment attachment in item.Attachments) 32 { 33 Console.Out.WriteLine("\t{0} ({1}, {2}, {3} bytes)", attachment.Name, attachment.MimeType, attachment.ContentDisposition, attachment.Size); 34 } 35 } 36 37 Console.Out.WriteLine("Finished"); 38 Console.ReadLine(); 39 } 40 } 41 }This is a console application, so you'll just have to replace the main class of a newly created console application with this code. Then, add a reference to my library (At least version 0.99.2).The most tricky part here clearly is the modification of the constraints in line 17; The default constraint is initialized with this value: 1 _Searcher.Constraints = string.Format(CultureInfo.InvariantCulture, "(\"{0}\" = false) ", WellknownProperties.Dav.IsFolder);This restricts the result set to child elements which are not folders. To restrict the result set further, you can just append additional constraints with an "AND". The full constraint being used here is this: 1 ("DAV:isfolder" = false) AND Cast("http://schemas.microsoft.com/mapi/proptag/xe1b000b" as "boolean") = trueYou'll probably wonder why I used the MAPI property 0xe1b00b instead of the urn:schemas:httpmail:hasattachment property. In the past, I've found the latter property not very reliable - it was false, even though a message had an attachment. And since I'm using a non-standard property here, I have to cast it to boolean to make the request work. If you don't do this, you'll end up with a Bad Request error from exchange.http://www.infini-tec.de/pingback.axdhttp://www.infini-tec.de/post.aspx?id=23f8ac2c-48f9-4d86-bb92-25c29580604f3http://www.infini-tec.de/trackback.axd?id=23f8ac2c-48f9-4d86-bb92-25c29580604fhttp://www.infini-tec.de/post/2007/02/11/Enumerating-attachments-in-a-users-inbox-folder.aspx#commenthttp://www.infini-tec.de/syndication.axd?post=23f8ac2c-48f9-4d86-bb92-25c29580604fhttp://www.infini-tec.de/post/2007/02/10/Exchange-library-updated-again.aspxExchange library updated again2007-02-09T23:00:00+00:00hkrause<div xmlns="http://www.w3.org/1999/xhtml"><p>This is a maintenance update with a number of bugfixes and a few new features to ease access to child items and folders: The Folder classes now expose two properties, ChildItems and ChildFolders, which provide access to the child elements of the folder. Both, the ItemCollection and the FolderCollection, have a Refresh operation, which must be called before the child elements can be accessed. Furthermore, both classes have a Constraints property, which restricts the items enumerated by the Refresh operation. Here is a class diagram of the new classes:</p><p><a href=file.axd?file=infinitec_exchange_0_99_2/a06624a5284d5c.jpg style="margin-right: 10px; display: block;"><img src=file.axd?file=infinitec_exchange_0_99_2/preview_a06624a5284d5c.jpg title="Class diagram of the ItemCollection and FolderCollection classes" float="false" style=";border: none;" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" /><br /><span style="font-size: 8pt;font-style: italic;text-align: right;clear: left;">Class diagram of the ItemCollection and FolderCollection classes (click to enlarge)</span></a></p><p>I will post an example tomorrow on how to use these new methods to enumerate the attachments of all items in the inbox folder of a users mailbox.</p></div><h2 xmlns="http://www.w3.org/1999/xhtml">Changelog for this version</h2><div xmlns="http://www.w3.org/1999/xhtml"><ul style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" type="disc"><li>Many minor changes to comply with static code-analysis</li><li>Fixed an bug with the Mailbox class</li><li>Fixed several bugs in the Initialize() method of the typed item classes</li><li>New class FolderCollection, which provides access to subfolders of an item.</li><li>New class ItemCollection<ItemType>, which provide access to child elements of a folder</li><li>The Folder<ItemType> now have a property ChildItems</li><li>The Folder classes now has a property ChildFolders;</li><li>The Folder class now has a property ChildItems.</li><li>The Attachment.Name property is now more accurate</li><li>All Item and Folder classes now expose a method ResetSecurityDescriptor and ResetSecurityDescriptorAsync, which does exactly that.</li><li>The Contact, CalendarItem now sets the content class correctly on new items</li><li>The Find Method on the Searcher and Searcher<ItemType> has been renamed to FindAll</li><li>The FindAsync Method on the Searcher and Searcher<ItemType> has been renamed to FindAllAsync</li><li>New method FindPage on the Searcher and Searcher<ItemType> </li><li>New method FindPageAsync on the Searcher and Searcher<ItemType> </li><li>The constructor of FolderSecurity is now internal</li><li>Constructor in ContactEmailAddress now saves the displayname correctly</li><li>Upgraded the threading library to version 2.5.2. This fixes a bug with all the synchronous methods blocking in a deadlock.</li></ul></div><h2 xmlns="http://www.w3.org/1999/xhtml">Downloads</h2><table xmlns="http://www.w3.org/1999/xhtml"><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec_exchange_0_99_2/zip.gif /></td><td><a href=file.axd?file=infinitec_exchange_0_99_2/InfiniTec.Exchange.zip>InfiniTec.Exchange.zip</a> (1,858,836 Bytes)<br />Binaries, Source, Documentation and Example application of version 0.99.2</td></tr></table>2007-02-09T23:00:00+00:00hkrauseThis is a maintenance update with a number of bugfixes and a few new features to ease access to child items and folders: The Folder classes now expose two properties, ChildItems and ChildFolders, which provide access to the child elements of the folder. Both, the ItemCollection and the FolderCollection, have a Refresh operation, which must be called before the child elements can be accessed. Furthermore, both classes have a Constraints property, which restricts the items enumerated by the Refresh operation. Here is a class diagram of the new classes:I will post an example tomorrow on how to use these new methods to enumerate the attachments of all items in the inbox folder of a users mailbox.http://www.infini-tec.de/pingback.axdhttp://www.infini-tec.de/post.aspx?id=d8fdfaa3-0c55-4449-bf26-43d1f3567cc30http://www.infini-tec.de/trackback.axd?id=d8fdfaa3-0c55-4449-bf26-43d1f3567cc3http://www.infini-tec.de/post/2007/02/10/Exchange-library-updated-again.aspx#commenthttp://www.infini-tec.de/syndication.axd?post=d8fdfaa3-0c55-4449-bf26-43d1f3567cc3http://www.infini-tec.de/post/2007/01/28/Minor-update-on-the-Exchange-library.aspxMinor update on the Exchange library2007-01-27T23:00:00+00:00hkrause<div xmlns="http://www.w3.org/1999/xhtml">This is a minor update on the InfiniTec.Exchange library due to the issues found within the <a href="libraries/threading/infinitec_threading_2_5_1">multi threading library</a> today. The Example application has also been updated accordingly.</div><h2 xmlns="http://www.w3.org/1999/xhtml">Change log</h2><div xmlns="http://www.w3.org/1999/xhtml"><ul style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" type="disc"><li>Fixed a multi-threading bug in the ActiveDirectoryResolver class.</li><li>Upgraded the threading library to version 2.5.1. It's no longer necessary to call Control.Invoke() methods when reporting progress to the UI.</li></ul></div><h2 xmlns="http://www.w3.org/1999/xhtml">Downloads</h2><table xmlns="http://www.w3.org/1999/xhtml"><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec_exchange_0_99_1/zip.gif /></td><td><a href=file.axd?file=infinitec_exchange_0_99_1/InfiniTec.Exchange.zip>InfiniTec.Exchange.zip</a> (1,660,202 Bytes)<br />Source, binaries, documentation and example application for 0.99.1</td></tr></table>2007-01-27T23:00:00+00:00hkrauseThis is a minor update on the InfiniTec.Exchange library due to the issues found within the multi threading library today. The Example application has also been updated accordingly.http://www.infini-tec.de/pingback.axdhttp://www.infini-tec.de/post.aspx?id=4b680c5d-9236-484b-a559-38f41618e3ed0http://www.infini-tec.de/trackback.axd?id=4b680c5d-9236-484b-a559-38f41618e3edhttp://www.infini-tec.de/post/2007/01/28/Minor-update-on-the-Exchange-library.aspx#commenthttp://www.infini-tec.de/syndication.axd?post=4b680c5d-9236-484b-a559-38f41618e3edhttp://www.infini-tec.de/post/2007/01/27/Exchange-library-updated-again.aspxExchange library updated again2007-01-26T23:00:00+00:00hkrause<div xmlns="http://www.w3.org/1999/xhtml"><p>Again, an update on my exchange library.</p><p>This update fixes a bunch of issues (many thanks to Mr. Heinen for his input), and some new features, as listed in the change log below.</p><h3>Messing with distribution lists</h3><div><p>This release adds experimental support for distribution lists in exchange folder. But instead of relying on the OWA commands to decode them (as described <a href="articles/exchange/exchangedistlist">here</a>), I decoded the binary member properties. Turned out, that the entry ids contained in that folder can be translated into a permannt url. </p><p>This release allows only read-only access to the member list.</p><p>The Members property of the DistributionList class returns a list of IAddressEntry instances. This interface currently exposes only one property, the name of the element. The element is one of the following:</p><ul style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" type="disc"><li><strong>User</strong> - A reference to an Active Directory user.</li><li><strong>Contact</strong> - A reference to an Active Directory contact</li><li><strong>Group</strong> - A reference to an Active Directory group</li><li><strong>DistributionList</strong> - A nested distribution list</li><li><strong>EmailAddress</strong> - A so called One-Off member. This is just name with an email address.</li></ul></div><h3>Calendar permissions</h3><div>When giving other people access to a calendar folder on a mailbox, it's not enough, to set those permissions on the calendar folder itself. The trustee must be given access to the local free busy data as well (This folder resides in the NON_IPM_SUBTREE/FreeBusy Data folder). The Mailbox class now returns a special folder instance for the mailbox.Calendar folder which handles this. More information on this topic can be found <a href="http://support.microsoft.com/kb/237924/en-us">here</a>.</div></div><h2 xmlns="http://www.w3.org/1999/xhtml">Changelog for version 0.99</h2><div xmlns="http://www.w3.org/1999/xhtml"><ul style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" type="disc"><li>Connection class now implements IDisposable (explicit implementation) and has a Close() method. Call either of these methods to close the underlying active directory connection.</li><li>Optimized the resolution of mailbox urls.</li><li>Added DistributionList class, which provides read-only access to the members of a distribution list stored on an Exchange folder.</li><li>Added new CalendarFolder class, which is returned from the Mailbox class. This class propagates security changes made to the folder to the local free/busy folder, as described in KB (237924). See <a href="http://support.microsoft.com/kb/237924/en-us">http://support.microsoft.com/kb/237924/en-us</a>.</li><li>Fixed several NullReferenceExceptions</li><li>Fixed some issues with TaskItem and CalendarItem</li><li>Added some validation logic to TaskItem and CalendarItem</li><li>Added some auto-calculations to the TaskItem an CalendarItem (e.g. End = Start + Duration and so on, modifying IsAllDayEvent accordingly)</li><li>Added the GetContent and SetContent functionality to the Item class</li><li>Fixed a bug with the PUT method (and the SetContent functionality as well)</li><li>Fixed a bug with setting the Free/Busy property on CalendarItems</li><li>Fixed a bug in the save method which occured when the Save operation was called when no properties were changed.</li><li>The SetContent and Attachment.Add methods now require a content type to be specified</li><li>New Class WellknownContentTypes, which has some definitions of common content types.</li><li>Renamed the FreeBusyType OOF to OutOfOffice</li><li>Removed the SearchScope property from the SearcherBase class, as it was redundant. Use the Scope property instead.</li></ul></div><h2 xmlns="http://www.w3.org/1999/xhtml">Downloads</h2><table xmlns="http://www.w3.org/1999/xhtml"><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec_exchange_0_99/zip.gif /></td><td><a href=file.axd?file=infinitec_exchange_0_99/InfiniTec.Exchange_0.99.zip>InfiniTec.Exchange_0.99.zip</a> (2,023,427 Bytes)<br />All-in-wonder package, including source, binaries, documentation and example application.</td></tr></table>2007-01-26T23:00:00+00:00hkrauseAgain, an update on my exchange library.This update fixes a bunch of issues (many thanks to Mr. Heinen for his input), and some new features, as listed in the change log below.This release adds experimental support for distribution lists in exchange folder. But instead of relying on the OWA commands to decode them (as described here), I decoded the binary member properties. Turned out, that the entry ids contained in that folder can be translated into a permannt url. This release allows only read-only access to the member list.The Members property of the DistributionList class returns a list of IAddressEntry instances. This interface currently exposes only one property, the name of the element. The element is one of the following:User - A reference to an Active Directory user.Contact - A reference to an Active Directory contactGroup - A reference to an Active Directory groupDistributionList - A nested distribution listEmailAddress - A so called One-Off member. This is just name with an email address.When giving other people access to a calendar folder on a mailbox, it's not enough, to set those permissions on the calendar folder itself. The trustee must be given access to the local free busy data as well (This folder resides in the NON_IPM_SUBTREE/FreeBusy Data folder). The Mailbox class now returns a special folder instance for the mailbox.Calendar folder which handles this. More information on this topic can be found here.http://www.infini-tec.de/pingback.axdhttp://www.infini-tec.de/post.aspx?id=4eae537a-62a3-4669-8862-4ae05f86a58b0http://www.infini-tec.de/trackback.axd?id=4eae537a-62a3-4669-8862-4ae05f86a58bhttp://www.infini-tec.de/post/2007/01/27/Exchange-library-updated-again.aspx#commenthttp://www.infini-tec.de/syndication.axd?post=4eae537a-62a3-4669-8862-4ae05f86a58bhttp://www.infini-tec.de/post/2007/01/07/Exchange-library-updated-again.aspxExchange library updated again2007-01-06T23:00:00+00:00hkrause<div xmlns="http://www.w3.org/1999/xhtml"><p>Here is another update on the InfiniTec.Exchange library. Among a few bug fixes, there are several new classes which simplify access to the Exchange store. Here is a class diagram of those classes:</p><p><a href=file.axd?file=infinitec.exchange_0.98/18eec53eede940d6.jpg style="margin-right: 10px; display: block;"><img src=file.axd?file=infinitec.exchange_0.98/preview_18eec53eede940d6.jpg title="Class diagram of Active Directory integration" float="false" style=";border: none;" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" /><br /><span style="font-size: 8pt;font-style: italic;text-align: right;clear: left;">Class diagram of Active Directory integration (click to enlarge)</span></a></p><p>To get the address of a users mailbox, you can now use the <strong>User</strong> class, which exposes a property named <strong>Mailbox</strong>. Be sure to call the <strong>Refresh </strong>or <strong>RefreshAsync</strong> method before accessing it. </p><p>To get a user object, you can either traverse the address lists defined in the Exchange organization by using the <strong>AddressListManager</strong> class.</p><p>Another way is to use the <strong>UserResolver</strong> which uses "ambiguous name resolution" and "search by initials" to find users: Specifying a <strong>Filter</strong> of jd will return John Doe. Specifiy john will do return all users with the name joe. This is essentially, what Outlook does when you execute the "Resolve Name" function. But in this case, the users contact folder is not searched.</p><h3>Permissions needed</h3><div>The problem with resolving the mailbox url or enumerating the address lists is that these operations require access to the Exchange configuration in the Active Directory. This data is stored under CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=primary_domain. By default, normal users do not have access to this data.</div></div><h2 xmlns="http://www.w3.org/1999/xhtml">Downloads</h2><table xmlns="http://www.w3.org/1999/xhtml"><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange_0.98/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange_0.98/InfiniTec.Exchange.Release_0.98.zip>InfiniTec.Exchange.Release_0.98.zip</a> (386,492 Bytes)<br />Release Build of version 0.98</td></tr><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange_0.98/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange_0.98/InfiniTec.Exchange_Source_0.98.zip>InfiniTec.Exchange_Source_0.98.zip</a> (301,731 Bytes)<br />Source code of version 0.98</td></tr><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange_0.98/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange_0.98/InfiniTec.Exchange_Documentation_0.98.zip>InfiniTec.Exchange_Documentation_0.98.zip</a> (768,932 Bytes)<br />Documentation</td></tr><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange_0.98/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange_0.98/ExampleApplication_0.98.zip>ExampleApplication_0.98.zip</a> (279,372 Bytes)<br />Example application</td></tr></table>2007-01-06T23:00:00+00:00hkrauseHere is another update on the InfiniTec.Exchange library. Among a few bug fixes, there are several new classes which simplify access to the Exchange store. Here is a class diagram of those classes:To get the address of a users mailbox, you can now use the User class, which exposes a property named Mailbox. Be sure to call the Refresh or RefreshAsync method before accessing it. To get a user object, you can either traverse the address lists defined in the Exchange organization by using the AddressListManager class.Another way is to use the UserResolver which uses "ambiguous name resolution" and "search by initials" to find users: Specifying a Filter of jd will return John Doe. Specifiy john will do return all users with the name joe. This is essentially, what Outlook does when you execute the "Resolve Name" function. But in this case, the users contact folder is not searched.The problem with resolving the mailbox url or enumerating the address lists is that these operations require access to the Exchange configuration in the Active Directory. This data is stored under CN=Microsoft Exchange,CN=Services,CN=Configuration,DC=primary_domain. By default, normal users do not have access to this data.http://www.infini-tec.de/pingback.axdhttp://www.infini-tec.de/post.aspx?id=bb890325-02dc-40de-9117-e3b1b0201b6b0http://www.infini-tec.de/trackback.axd?id=bb890325-02dc-40de-9117-e3b1b0201b6bhttp://www.infini-tec.de/post/2007/01/07/Exchange-library-updated-again.aspx#commenthttp://www.infini-tec.de/syndication.axd?post=bb890325-02dc-40de-9117-e3b1b0201b6bhttp://www.infini-tec.de/post/2007/01/02/Exchange-Library-097.aspxExchange Library 0.972007-01-01T23:00:00+00:00hkrause<div xmlns="http://www.w3.org/1999/xhtml"><p>It's time for a new update to my Exchange access library. Again, several breaking changes, as the number of classes grow. So, here is the new class diagram:</p><p><a href=file.axd?file=infinitec.exchange_0.97/e94550e9cf0644eb.jpg style="margin-right: 10px; display: block;"><img src=file.axd?file=infinitec.exchange_0.97/preview_e94550e9cf0644eb.jpg float="false" style=";border: none;" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" /><br /><span style="font-size: 8pt;font-style: italic;text-align: right;clear: left;"> (click to enlarge)</span></a></p><p>And there are a few more classes worth writing about: The Searcher<ItemType> is a Searcher class which returns MessageItems, CalendarItems and so on. Next, the Folder<ItemType> implements the folder functionality for the same classes. And finally, the Mailbox class provides access to the wellknown folders like Calendar, Inbox, Outbox and so on - language independent. So, here is the diagram for these classes:</p><p><div class="margin-right: 10px; display: block; width:600px;"><img src=file.axd?file=infinitec.exchange_0.97/396cc163a934db6.jpg float="false" style=";border: none;" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" /><br /><span style="font-size: 8pt;font-style: italic;text-align: right;clear: left;"></span></div></p><p>If you have comments or if you found an error, please drop me a note.</p></div><h2 xmlns="http://www.w3.org/1999/xhtml">Changelog for this version</h2><div xmlns="http://www.w3.org/1999/xhtml"><ul style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" type="disc"><li>The Item class now has most of the methods from the SimpleItem class: Delete, Copy, Move</li><li>The host of the url passed to the an Item or Folder class now checks the IP addresses of the specified hostname instead of the literal hostname. If an IP address is specified as a server, no DNS resolution is attempted.</li><li>New Searcher<ItemType> class. Allows to directly search for tasks, appointments, calendaritems..</li><li>New Folder<ItemType> class. </li><li>New Mailbox class which provides language-independent access to the wellknown folders like inbox, outbox, tasks...</li><li>Renamed Item to SimpleItem</li><li>Renamed TypedItemBase to Item</li><li>Renamed Task to TaskItem</li><li>Renamed Contact to ContactItem</li><li>Renamed Message to MessageItem</li><li>Item is no longer abstract</li><li>Item and its descendents now all have a parameterless constructor</li><li>Fixed a bug in the ContactItem class which prevented a successful save operation</li><li>Fixed several bugs in the security logic.</li></ul></div><h2 xmlns="http://www.w3.org/1999/xhtml">Downloads</h2><table xmlns="http://www.w3.org/1999/xhtml"><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange_0.97/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange_0.97/InfiniTec.Exchange_0.97_Binaries.zip>InfiniTec.Exchange_0.97_Binaries.zip</a> (253,065 Bytes)<br />Binaries for version 0.97, strong-named</td></tr><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange_0.97/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange_0.97/ExampleApplication.zip>ExampleApplication.zip</a> (501,698 Bytes)<br />Example application for version 0.97</td></tr><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange_0.97/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange_0.97/InfiniTec.Exchange_0.97_Source.zip>InfiniTec.Exchange_0.97_Source.zip</a> (855,323 Bytes)<br />Source files for version 0.97</td></tr><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange_0.97/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange_0.97/Documentation_0.97.zip>Documentation_0.97.zip</a> (667,023 Bytes)<br />Documentation for version 0.97.</td></tr></table>2007-01-01T23:00:00+00:00hkrauseIt's time for a new update to my Exchange access library. Again, several breaking changes, as the number of classes grow. So, here is the new class diagram:And there are a few more classes worth writing about: The Searcher<ItemType> is a Searcher class which returns MessageItems, CalendarItems and so on. Next, the Folder<ItemType> implements the folder functionality for the same classes. And finally, the Mailbox class provides access to the wellknown folders like Calendar, Inbox, Outbox and so on - language independent. So, here is the diagram for these classes:If you have comments or if you found an error, please drop me a note.http://www.infini-tec.de/pingback.axdhttp://www.infini-tec.de/post.aspx?id=27b89c21-2634-4a69-b8e6-590178cc637c0http://www.infini-tec.de/trackback.axd?id=27b89c21-2634-4a69-b8e6-590178cc637chttp://www.infini-tec.de/post/2007/01/02/Exchange-Library-097.aspx#commenthttp://www.infini-tec.de/syndication.axd?post=27b89c21-2634-4a69-b8e6-590178cc637chttp://www.infini-tec.de/post/2006/10/29/New-version-of-the-Exchange-class-library.aspxNew version of the Exchange class library2006-10-28T22:00:00+00:00hkrause<div xmlns="http://www.w3.org/1999/xhtml"><p>This is a bug-fix release.</p><p>Changelog:</p><ul style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" type="disc"><li>Fixed a bug in the Security logic. It is now possible to set permissions on groups (security and distribution) without destroying the security descriptor</li><li>Fixed a bug with MultiValued properties</li><li>Fixed a bug with the Duedate property of tasks</li><li>Fixed a bug which prevented the manipulation of properties which names started with 0x</li><li>Removed the set part of the Task.IsComplete property. This has been replaced by a SetComplete(DateTime) method.</li><li>Added an IconIndex enumeration and changed the data type of the TypedItemBase.IconIndex from int? to IconIndex?</li><li>Fixed a bug in the Attachment class</li></ul></div><h2 xmlns="http://www.w3.org/1999/xhtml">Downloads</h2><table xmlns="http://www.w3.org/1999/xhtml"><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange_october/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange_october/InfiniTec.Exchange_0.96_Source.zip>InfiniTec.Exchange_0.96_Source.zip</a> (223,936 Bytes)<br />InfiniTec.Exchange 0.96 Source code</td></tr><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange_october/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange_october/InfiniTec.Exchange_0.96_Release.zip>InfiniTec.Exchange_0.96_Release.zip</a> (239,684 Bytes)<br />InfiniTec.Exchange 0.96 binaries, signed with the InfiniTec private key. Release-Build with debug symbols</td></tr><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange_october/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange_october/InfiniTec.Exchange_Documentation.zip>InfiniTec.Exchange_Documentation.zip</a> (818,848 Bytes)<br />Documentation as CHM file</td></tr><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange_october/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange_october/InfiniTec.Exchange_ExampleApplication.zip>InfiniTec.Exchange_ExampleApplication.zip</a> (453,545 Bytes)<br />Example application</td></tr></table>2006-10-28T22:00:00+00:00hkrauseThis is a bug-fix release.Changelog:Fixed a bug in the Security logic. It is now possible to set permissions on groups (security and distribution) without destroying the security descriptorFixed a bug with MultiValued propertiesFixed a bug with the Duedate property of tasksFixed a bug which prevented the manipulation of properties which names started with 0xRemoved the set part of the Task.IsComplete property. This has been replaced by a SetComplete(DateTime) method.Added an IconIndex enumeration and changed the data type of the TypedItemBase.IconIndex from int? to IconIndex?Fixed a bug in the Attachment classhttp://www.infini-tec.de/pingback.axdhttp://www.infini-tec.de/post.aspx?id=be56a5aa-acd3-4708-b97a-2550e71904dd0http://www.infini-tec.de/trackback.axd?id=be56a5aa-acd3-4708-b97a-2550e71904ddhttp://www.infini-tec.de/post/2006/10/29/New-version-of-the-Exchange-class-library.aspx#commenthttp://www.infini-tec.de/syndication.axd?post=be56a5aa-acd3-4708-b97a-2550e71904ddhttp://www.infini-tec.de/post/2006/09/17/InfiniTecExchange-095-released.aspxInfiniTec.Exchange 0.95 released2006-09-16T22:00:00+00:00hkrause<div xmlns="http://www.w3.org/1999/xhtml"><p>This is another release of my InfiniTec.Exchange package (for a complete list of features see <a href="libraries/exchange/infinitec.exchange">here</a>). This version fixes some bugs and adds Outlook-Object-model like classes, which provides strong-typed access to the properties of the different item types. Supported item types are Appointments, Contacts, Messages and Tasks:</p><p><a href=file.axd?file=infinitec.exchange_september/49019e85c4d24ec0.jpg style="margin-right: 10px; display: block;"><img src=file.axd?file=infinitec.exchange_september/preview_49019e85c4d24ec0.jpg title="Classdiagram of the outlook-like object model" float="false" style=";border: none;" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" /><br /><span style="font-size: 8pt;font-style: italic;text-align: right;clear: left;">Classdiagram of the outlook-like object model (click to enlarge)</span></a></p><p> </p><p>What is missing is a Searcher class which returns instances of those classes. Additionally, recurrence patterns are quite complicated and not implemented in this release. I will add them in a later release.</p><p> </p></div><h2 xmlns="http://www.w3.org/1999/xhtml">ChangeLog</h2><div xmlns="http://www.w3.org/1999/xhtml"><p>These are the changes in the 0.95 release:</p><ul style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" type="disc"><li>Added the ability to search multiple roots at once to the Searcher class.</li><li>Renamed Scope enum to Depth</li><li>Entities in properties are now automatically decoded.</li><li>Fixed an error in the PROPFIND method</li><li>Properties with a localname starting with 0x are now correctly handled (for example http://schemas.microsoft.com/mapi/id/{00062002-0000-0000-C000-000000000046}/0x0000825e).</li><li>(Hopefully) fixed a bug with attachments</li><li>Fixed a bug which occured when saving changes to DateTime properties.</li><li>Moved several classes between namespaces... </li><li>New Outlook-Object model like classes: CalendarItem, Contact, Message, Task. Recurrence-handling on tasks and appointments is not currently supported. This will be added with a later release.</li></ul></div><h2 xmlns="http://www.w3.org/1999/xhtml">Downloads</h2><table xmlns="http://www.w3.org/1999/xhtml"><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange_september/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange_september/InfiniTec.Exchange_Release.zip>InfiniTec.Exchange_Release.zip</a> (189,307 Bytes)<br />InfiniTec.Exchange 0.95 Release files</td></tr><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange_september/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange_september/InfiniTec.Exchange%20Source.zip>InfiniTec.Exchange Source.zip</a> (168,330 Bytes)<br />InfiniTec.Exchange 0.95 Source files</td></tr><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange_september/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange_september/Documentation.zip>Documentation.zip</a> (709,606 Bytes)<br />Documentation</td></tr><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange_september/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange_september/ExampleApplication.zip>ExampleApplication.zip</a> (452,989 Bytes)<br />Example application</td></tr></table>2006-09-16T22:00:00+00:00hkrauseThis is another release of my InfiniTec.Exchange package (for a complete list of features see here). This version fixes some bugs and adds Outlook-Object-model like classes, which provides strong-typed access to the properties of the different item types. Supported item types are Appointments, Contacts, Messages and Tasks: What is missing is a Searcher class which returns instances of those classes. Additionally, recurrence patterns are quite complicated and not implemented in this release. I will add them in a later release. http://www.infini-tec.de/pingback.axdhttp://www.infini-tec.de/post.aspx?id=d8956222-c7aa-4c4d-be09-2ed77280d7ae0http://www.infini-tec.de/trackback.axd?id=d8956222-c7aa-4c4d-be09-2ed77280d7aehttp://www.infini-tec.de/post/2006/09/17/InfiniTecExchange-095-released.aspx#commenthttp://www.infini-tec.de/syndication.axd?post=d8956222-c7aa-4c4d-be09-2ed77280d7aehttp://www.infini-tec.de/post/2006/05/14/InfiniTecExchange.aspxInfiniTec.Exchange2006-05-13T22:00:00+00:00hkrause<div xmlns="http://www.w3.org/1999/xhtml"><strong>This article has been superseeded by this </strong><a href="libraries/exchange/infinitec.exchange_september"><strong>article</strong></a><strong>.</strong></div><h2 xmlns="http://www.w3.org/1999/xhtml">Introduction</h2><div xmlns="http://www.w3.org/1999/xhtml"><p>This library is the successor to my WebDAVLayer. In fact, the WebDAVLayer was never meant to be released to the public and had no documentation. As such, the library was very difficult to use.</p><p>Another problem was the lack of asynchronous methods. Because of this, the library did not scale well.</p><p>This new release is a complete rewrite of that library and provides a very simple set of classes. Additionally, everything is documented and an example application is included.</p></div><h2 xmlns="http://www.w3.org/1999/xhtml">Why only .NET 2.0?</h2><div xmlns="http://www.w3.org/1999/xhtml">A recent question I got was whether I would release a version of this library which could be compiled with .NET 1.1. The reason, why I will not do this is because of the heavy usage of .NET 2.0 features, like generics and iterators. It would be a major rewrite of the library, and for all future releases I would have to maintain two branches. Since I do this in my spare time, that would be to much work.</div><h2 xmlns="http://www.w3.org/1999/xhtml">Status</h2><div xmlns="http://www.w3.org/1999/xhtml"><p>This is an early beta version. You should expect that some features still do not work as expected. </p><p>Many features are not yet implemented. This includes support for the WebDAV SUBSCRIBE methods, support for batch operations (BMOVE and BCOPY), recovering of deleted items and discovery mechanisms.</p><p>Be extremely careful when settings permission. Do set permissions with this version of the library on on a production server, because it may corrupt the security descriptor on the folder. If you accidently messed up a security descriptor, you can use the <a href="http://www.microsoft.com/downloads/details.aspx?FamilyID=635be792-d8ad-49e3-ada4-e2422c0ab424&DisplayLang=en">PfDavAdminTool</a> to correct those descriptors.</p></div><h2 xmlns="http://www.w3.org/1999/xhtml">Structure</h2><div xmlns="http://www.w3.org/1999/xhtml"><p>The main classes are displayed below:</p><p><a href=file.axd?file=infinitec.exchange/1ad85429f684a8c.jpg style="margin-right: 10px; display: block;"><img src=file.axd?file=infinitec.exchange/preview_1ad85429f684a8c.jpg title="InfiniTec.Exchange class diagram" float="false" style=";border: none;" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" /><br /><span style="font-size: 8pt;font-style: italic;text-align: right;clear: left;">InfiniTec.Exchange class diagram (click to enlarge)</span></a></p><p>The entry point is the Connection class. This class specifies the context information for the WebDAV requests. To create a new connection, this code can be used:</p><div class="clsCode" style="FONT-SIZE: 10pt; BACKGROUND-COLOR: #f0f0f0"><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 1</span> <span style="color: #008080;">Connection</span> connection = <span style="color: #0000ff;">new</span><span style="color: #008080;">Connection</span>();</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 2</span> </span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 3</span> connection.ConnectionProtocol = <span style="color: #008080;">ConnectionProtocol</span>.Http;</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 4</span> </span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 5</span> connection.Server = <span style="color: #800000;">"myserver"</span>;</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 6</span> connection.Credential.Username = <span style="color: #800000;">"administrator"</span>;</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 7</span> connection.Credential.Password = <span style="color: #800000;">"password"</span>;</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 8</span> connection.Credential.AuthenticationType = <span style="color: #008080;">AuthenticationType</span>.Basic;</span></p></div><p>This connection can now be used to instantiate one of the other classes:</p><div class="clsCode" style="FONT-SIZE: 10pt; BACKGROUND-COLOR: #f0f0f0"><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 1</span> <span style="color: #008080;">Item</span> item = <span style="color: #0000ff;">new</span><span style="color: #008080;">Item</span>(<span style="color: #800000;">"public/my folder"</span><span style="color: #000000;">, connection);</span></span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 2</span> item.Refresh();</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 3</span> </span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 4</span> <span style="color: #0000ff;">bool</span> isHidden = item.Properties.GetProperty<<span style="color: #0000ff;">bool</span>>(<span style="color: #008080;">Namespaces</span>.Dav, <span style="color: #800000;">"ishidden")</span>.Value;</span></p></div><p>All operations are available in a synchronous version as well as an asynchronous version. The above refresh operation can also be called asynchronously:</p><div class="clsCode" style="FONT-SIZE: 10pt; BACKGROUND-COLOR: #f0f0f0"><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 1</span> <span style="color: #008080;">Item</span> item = <span style="color: #0000ff;">new</span><span style="color: #008080;">Item</span>(<span style="color: #800000;">"public/my folder"</span>, connection);</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 2</span> item.RefreshCompleted += item_RefreshCompleted;</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 3</span> item.RefreshProgressChanged += item_RefreshProgressChanged;</span></p><p style="PADDING-RIGHT: 0px; MARGIN-TOP: 0px; PADDING-LEFT: 2cm; MARGIN-BOTTOM: 0px; TEXT-INDENT: -2cm"><span style="font-family: Courier New;"><span style="color: #2b91af;"> 4</span> item.RefreshAsync();</span></p></div><p>During the refresh operation, the ProgressChanged event is called multiple times. When the operation finishes, the Completed event is called.</p></div><h2 xmlns="http://www.w3.org/1999/xhtml">Managing security on items</h2><div xmlns="http://www.w3.org/1999/xhtml"><p>The Folder.GetSecurity() and Item.GetSecurity() methods provide access to the security descriptors on Exchange folder and items. Unlike Outlook, this package allows permissions to be set on every item, not only on folders.</p><p>The basic classes for manipulation of security descriptors are displayed in this class diagram:</p><p><div class="margin-right: 10px; display: block; width:600px;"><img src=file.axd?file=infinitec.exchange/40c9ade8685c47f9.jpg title="Classdiagram of Exchange security descriptors" float="false" style=";border: none;" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" /><br /><span style="font-size: 8pt;font-style: italic;text-align: right;clear: left;">Classdiagram of Exchange security descriptors</span></div></p><p>The GetAccessControlEntries() method of either the FolderSecurity or ItemSecurity class returns a collection of ItemAce (or FolderAce respectively), which look like this:</p><p><a href=file.axd?file=infinitec.exchange/1296a453a5974a7f.jpg style="margin-right: 10px; display: block;"><img src=file.axd?file=infinitec.exchange/preview_1296a453a5974a7f.jpg title="Class diagram of the security system" float="false" style=";border: none;" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xhtml="http://www.w3.org/1999/xhtml" xmlns:xd="http://schemas.microsoft.com/office/infopath/2003" /><br /><span style="font-size: 8pt;font-style: italic;text-align: right;clear: left;">Class diagram of the security system (click to enlarge)</span></a></p><p>Three different levels of access masks are used: </p><ul style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" type="disc"><li>The AccessRole define the eight standard roles also defined by Outlook. Additionally, the FolderVisible role is defined. This enumeration is only defined on folder objects.</li><li>The AccessMasks enumeration represents the basic access operations used in Outlook. These access masks applies both to items and folders.</li><li>The FolderAccessMasks and ItemAccessMasks define the low-level permissions on folders and items.</li></ul><p>To set permission on folder and items, use the SetSecurity() method of the ItemAce or FolderAce class. Be extremely careful if you want to set the ItemAccessMasks or FolderAccessMasks directly. The corresponding methods do have the <em>Dangerous</em> prefix for a reason!</p></div><h2 xmlns="http://www.w3.org/1999/xhtml">ChangeLog</h2><div xmlns="http://www.w3.org/1999/xhtml"><h3>Version 0.93 - 07-23-06</h3><div><ul style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" type="disc"><li>Fixed several issues with FormBased authentication</li><li>New FormbasedAuthenticationRequiredException, which is thrown when an attempt is made to access an item which requires form based authentication.</li><li>Moved the DangerousSetAccess method from the ExchangeSecurity to the ItemSecurity</li><li>Added a DangererousSetAccess method to the FolderSecurity class.</li><li>Fixed an error in the ItemSecurity.SetAccess(AccessMasks) and FolderSecurity.SetAccess(AccessMasks) method (NullReferenceException).</li><li>All methods calling event handler (OnRefreshCompleted, etc.) are now "protected virtual"</li><li>Added Attachment handling (via the Item.Attachments property). Attachments can be enumerated, added and removed.</li><li>All EventHandler<ProgressChangedEventArgs<RequestStatus>> have been replaced with a ProgressChangedEventHandler<RequestStatus></li><li>The RefreshScope has been removed</li><li>The RefreshStatus has been removed</li><li>The Refresh operations of the Item class do not have a parameter any longer</li><li>RequestStatus.BeginningFormBasedAuthentication renamed to RequestStatus.PerformingFormBasedAuthentication.</li><li>The Item class now has a GetContent/GetContentAsync and a SetContent/SetContentAsync methods operation which allow downloading/setting the the MIME content of the item.<br /></li></ul></div><h3>Version 0.92 - 05-21-06</h3><div><ul style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" type="disc"><li>Fixed a bug in the PropertyCollection.Contains method</li><li>Added several TryGetProperty and TryGetMultiValuedProperty methods to the PropertyValueCollection</li><li>Added GetSecurity() methods to the Item and Folder class, which provides access to the security descriptor of that item</li><li>Added classes for manipulation of the security descriptors of an item</li></ul></div><h3>Version 0.91 - 05-17-06</h3><div><ul style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" type="disc"><li>Properties are now strongly typed. Single-Valued properties are of type Property<T> and multi valued properties are of type MultiValuedProperty<T></li><li>Removed the IsMultiValued and Type properties from the Property class. On a refresh operation, the HTTP result is now reflected in each property.</li><li>The Properties collection now contains properties which could not be successfully loaded. Those properties are of type Property and have a Property.Status.StatusCode != HttpStatusCode.Ok.</li><li>When a property is accessed via the Item.Properties indexer or any other of the GetProperty<T> or GetMultiValuedProperty<T> methods, an exception is thrown, whenever the Property.Status.StatusCode != HttpStatusCode.Ok.</li></ul></div><h3>Version 0.9 - 05-15-06</h3><div><ul style="MARGIN-TOP: 0px; MARGIN-BOTTOM: 0px" type="disc"><li>Initial release</li></ul></div></div><h2 xmlns="http://www.w3.org/1999/xhtml">Downloads</h2><table xmlns="http://www.w3.org/1999/xhtml"><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange/InfiniTec.Exchange_Release.zip>InfiniTec.Exchange_Release.zip</a> (129,280 Bytes)<br />Version 0.93 release compile including debug symbol, signed with the InfiniTec private key</td></tr><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange/Documentation.zip>Documentation.zip</a> (251,173 Bytes)<br />Documentation as CHM file</td></tr><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange/InfiniTec.Exchange_Source.zip>InfiniTec.Exchange_Source.zip</a> (91,769 Bytes)<br />Source code version 0.93</td></tr><tr><td><img style="border:none; vertical-align: middle;" src=file.axd?file=infinitec.exchange/zip.gif /></td><td><a href=file.axd?file=infinitec.exchange/ExampleApplication.zip>ExampleApplication.zip</a> (66,862 Bytes)<br />Example application</td></tr></table>2006-05-13T22:00:00+00:00hkrauseThis class implements methods to access Exchange public or private folders using the WebDAV protocol.http://www.infini-tec.de/pingback.axdhttp://www.infini-tec.de/post.aspx?id=2f13fa43-69a4-4a5d-bc92-7541bc9af5473http://www.infini-tec.de/trackback.axd?id=2f13fa43-69a4-4a5d-bc92-7541bc9af547http://www.infini-tec.de/post/2006/05/14/InfiniTecExchange.aspx#commenthttp://www.infini-tec.de/syndication.axd?post=2f13fa43-69a4-4a5d-bc92-7541bc9af547