<?xml version="1.0" encoding="utf-8"?>
<rss xmlns:atom="https://www.w3.org/2005/Atom" xmlns:sy="https://purl.org/rss/1.0/modules/syndication/" xmlns:dc="https://purl.org/dc/elements/1.1/" xmlns:content="https://purl.org/rss/1.0/modules/content/" xmlns:wfw="https://wellformedweb.org/CommentAPI/" xmlns:slash="https://purl.org/rss/1.0/modules/slash/"
  version="2.0">
  <channel>
    <title>Messaging Developer Dilemmas</title>
    <atom:link
      href="https://docs.microsoft.com/archive/blogs/dhruvkh/feed.xml"
      rel="self"
      type="application/rss+xml" />
    <link>https://docs.microsoft.com/archive/blogs/dhruvkh/feed.xml</link>
    <description>Insights into the latest in the Outlook/Exchange Developer World to help you/us resolve frustrations!</description>
    <lastBuildDate>Wed, 17 Apr 2019 04:06:55 GMT</lastBuildDate>
    <language>en-US</language>
    <sy:updatePeriod>hourly</sy:updatePeriod>
    <sy:updateFrequency>1</sy:updateFrequency>
    <item>
      <title>How To (and how not to) access Custom Attributes using GetExchangeUser</title>
      <link>https://docs.microsoft.com/archive/blogs/dhruvkh/how-to-and-how-not-to-access-custom-attributes-using-getexchangeuser</link>
      <pubDate>Tue, 12 Jun 2012 12:38:06 GMT</pubDate>
      <dc:creator><![CDATA[Dhruv Khattar]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhruvkh/2012/06/12/how-to-and-how-not-to-access-custom-attributes-using-getexchangeuser/</guid>
      <description><![CDATA[&#160;  The content of this blog stands true as of 13th of June, 2012. The behavior described...]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p><strong><font size="2">The content of this blog stands true as of 13th of June, 2012. The behavior described towards the end of the article may be corrected through a subsequent product update.</font></strong></p>  <p>&#160;</p>  <p>Out-of-the-box Custom Attributes were introduced starting Exchange Server 2007 to save you the trouble of having to modify your Active Directory Schema, as you had to in Exchange 2003 and earlier, to store custom information against AD users, such as EmployeeID etc. that Exchange doesn’t already provide for.</p>  <p>Usage of these in-built Custom Attributes over ones added by extending the AD Schema come with many advantages, all of which are documented here: <a title="https://technet.microsoft.com/en-us/library/ee423541.aspx" href="https://technet.microsoft.com/en-us/library/ee423541.aspx">https://technet.microsoft.com/en-us/library/ee423541.aspx</a></p>  <p>You might come across many a situation where you need to fetch information stored in one of the Custom Attributes in your code that uses the Outlook Object Model or the Outlook Interop Assemblies.</p>  <p>Values of custom attributes (among other extended properties) can be easily be read through the PropertyAccessor member (<a title="https://msdn.microsoft.com/en-us/library/bb147680%28v=office.12%29" href="https://msdn.microsoft.com/en-us/library/bb147680%28v=office.12%29">https://msdn.microsoft.com/en-us/library/bb147680%28v=office.12%29</a>) of the ExchangeUser object.</p>  <p>You would need to specify the Schema Names for each of the Custom Attributes, which would be of the format:</p>  <blockquote>   <p><font color="#0000ff">https://schemas.microsoft.com/mapi/proptag/&lt;Property</font><font color="#0000ff"> Tag&gt;</font></p> </blockquote>  <p>The property tags for ExtensionAttribute1 to ExtensionAttribute10 can be found here: <a href="https://support.microsoft.com/kb/178553">https://support.microsoft.com/kb/178553</a> but I’ve provided a code excerpt for you that fetches the values of all 15 custom attributes associated with the logged on user, below:</p>  <p>&#160;</p>  <blockquote>   <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Outlook.Recipient curUser = this.Application.Session.CurrentUser;     <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; ExchangeUser exchUserObj = curUser.AddressEntry.GetExchangeUser();      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; String[] propNames = new String[] { &quot;<font color="#ff0000"><strong>https://schemas.microsoft.com/mapi/proptag/0x802D001F</strong></font>&quot;,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;<font color="#ff0000"><strong>https://schemas.microsoft.com/mapi/proptag/0x802E001F</strong></font>&quot;,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;https://schemas.microsoft.com/mapi/proptag/0x802F001E&quot;,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;https://schemas.microsoft.com/mapi/proptag/0x8030001E&quot;,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;https://schemas.microsoft.com/mapi/proptag/0x8031001E&quot;,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;https://schemas.microsoft.com/mapi/proptag/0x8032001E&quot;,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;https://schemas.microsoft.com/mapi/proptag/0x8033001E&quot;,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;https://schemas.microsoft.com/mapi/proptag/0x8034001E&quot;,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;https://schemas.microsoft.com/mapi/proptag/0x8035001E&quot;,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;https://schemas.microsoft.com/mapi/proptag/0x8036001E&quot;,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;https://schemas.microsoft.com/mapi/proptag/0x8C57001E&quot;,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;https://schemas.microsoft.com/mapi/proptag/0x8C58001E&quot;,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;https://schemas.microsoft.com/mapi/proptag/0x8C59001E&quot;,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;https://schemas.microsoft.com/mapi/proptag/0x8C60001E&quot;,       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &quot;https://schemas.microsoft.com/mapi/proptag/0x8C61001E&quot; };</p> </blockquote>  <p>&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; object resultCustomAttributes; //An array to retrieve the values stored in each of the 15 Custom Attributes   <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; resultCustomAttributes = exchUserObj.PropertyAccessor.GetProperties(propNames);</p>  <p>&#160;</p>  <p>Unfortunately, it isn’t a mere gaffe on my part that I’ve marked the first 2 schema names corresponding to ExtensionAttribute1 and ExtensionAttribute2. It so happens that the values of these 2 specific attributes seem to be inaccessible via OOM at the moment. I’ve tested this behavior against the latest patched builds of Exchange Server 2007 and 2010.</p>  <p>The issue seems to be confined to OOM alone, since the values of the 2 attributes can be read successfully using Extended MAPI (which can be verified using tools that make Extended MAPI calls such as MFCMapi).</p>  <p>If you happen to be using such an implementation and you’re observing the issue, I’d recommend that you avoid using ExtensionAttribute1 and ExtensionAttribute2, until the issue is resolved.</p>  <p>Cheers!</p>]]></content:encoded>
    </item>
    <item>
      <title>Sending Appointments from EWS Apps: Where did my HTML go???</title>
      <link>https://docs.microsoft.com/archive/blogs/dhruvkh/sending-appointments-from-ews-apps-where-did-my-html-go</link>
      <pubDate>Fri, 18 May 2012 08:32:01 GMT</pubDate>
      <dc:creator><![CDATA[Dhruv Khattar]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhruvkh/2012/05/18/sending-appointments-from-ews-apps-where-did-my-html-go/</guid>
      <description><![CDATA[&#160;  Update: As on 25th May 2012, Roll Up 3 for Exchange Server 2010 SP2 addresses this issue....]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p><strong><font size="3"><font color="#ff0000">Update:</font> As on 25th May 2012, Roll Up 3 for Exchange Server 2010 SP2 addresses this issue. You can install this update from: </font></strong><a title="https://www.microsoft.com/en-us/download/details.aspx?id=29899" href="https://www.microsoft.com/en-us/download/details.aspx?id=29899"><strong><font size="3">https://www.microsoft.com/en-us/download/details.aspx?id=29899</font></strong></a></p>  <p><font size="3"><strong>You can read a description of the issue here: </strong></font><a title="https://support.microsoft.com/kb/2689810" href="https://support.microsoft.com/kb/2689810"><font size="3"><strong>https://support.microsoft.com/kb/2689810</strong></font></a></p>  <p>_____________________________</p>  <p><u>Disclaimer: The contents of this article stand true at the time of writing it, which is on the 18th of May, 2012. The last release to Exchange Server 2010 at this point is Rollup 2 for Service Pack 2. Behavior is expected to change (for better) in subsequent updates.</u></p>  <p>&#160; <br />So we’ve uncovered a rather peculiar issue existing in Exchange 2010 whereby if you use an Exchange Web Services application to generate and send out a meeting request whose body contains HTML formatting, you’ll observe that when you open the meeting item in Outlook, you might find that the HTML formatting of the text is missing. Interestingly, this behavior is observed when Outlook is running in Online Mode, though the content will be nice and HTML-formatted when Outlook is in Cached mode or you’re viewing it through Outlook Web Access.</p>  <p>Poof! Magic? Err… guess not.</p>  <p>This is due to a known issue that has been identified and fixed, and will in all probability be rolled out in a subsequent update to Exchange Server.</p>  <p>What we <em>have</em> done, though, is fixed this specific issue for <em>Recurring</em> items in Rollup 2 for Exchange 2010 Service Pack 2. So if you think this specific issue is going to cause a lot of controversy at your end, we have identified a possible work-around for you…</p>  <p>To implement this work-around:</p>  <ol>   <li>Have your organization’s Exchange Server 2010 patched to Service Pack 2 Rollup 2 (<a title="https://www.microsoft.com/en-us/download/details.aspx?id=29427" href="https://www.microsoft.com/en-us/download/details.aspx?id=29427)">https://www.microsoft.com/en-us/download/details.aspx?id=29427)</a>       <br /></li>    <li>Alter the code in the EWS application that you’ve written so as to make the meeting item Recurring. Naturally, the question is “Why would I make it recurring if it’s going to take place only once?”      <br />The answer is that you’re going down that road because you <em>need</em> HTML formatted e-mails generated out of your Exchange Web Services application to be accurately viewable in Outlook clients running specifically in Online Mode, and it cannot wait till the issue is addressed in a subsequent rollup/service pack.       <br />Also, we don’t really need to create <em>multiple </em>recurrences of a meeting item which has to take place only once. We create once recurring instance, and trick Outlook into thinking that it’s a recurring series. </li> </ol>  <p>So while traditionally, your code would’ve looked like this…</p>  <blockquote>   <p><font color="#c0504d">Appointment appointment = new Appointment(service);        <br />appointment.Subject = &quot;Recurring with proper HTML&quot;;         <br />        <br />appointment.Body = &quot;</font><font color="#666666"><font color="#666666">&lt;html&gt;&lt;body&gt;&lt;bold&gt;</font>Recurring Item&lt;/BOLD&gt;&lt;br /&gt;&lt;A href='</font><a href="https://www.bing.com'"><font color="#666666">https://www.bing.com'</font></a><font color="#c0504d"><font color="#666666">&gt;Bing&lt;/a&gt;&lt;p /&gt;&lt;Font face='Arial' size=15&gt;HTML formatted Body&lt;/font&gt;&lt;/body&gt;&lt;/html&gt;</font>&quot;;         <br />        <br />appointment.Body.BodyType = BodyType.HTML;         <br />appointment.Start = DateTime.Now.AddDays(1);         <br />appointment.End = appointment.Start.AddHours(2);         <br />appointment.Location = &quot;Conference Room&quot;;         <br />appointment.RequiredAttendees.Add(“recipient@domain.com”);</font></p>    <p><font color="#c0504d">appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy);        <br /></font></p> </blockquote>  <p>now it would have to read this…</p>  <blockquote>   <p>     <br /><font color="#c0504d">Appointment appointment = new Appointment(service);        <br />appointment.Subject = &quot;Recurring with proper HTML&quot;;         <br />        <br />appointment.Body = &quot;</font><font color="#666666">&lt;html&gt;&lt;body&gt;&lt;bold&gt;Recurring Item&lt;/BOLD&gt;&lt;br /&gt;&lt;A href='</font><a href="https://www.bing.com'"><font color="#666666">https://www.bing.com'</font></a><font color="#c0504d"><font color="#666666">&gt;Bing&lt;/a&gt;&lt;p /&gt;&lt;Font face='Arial' size=15&gt;HTML formatted Body&lt;/font&gt;&lt;/body&gt;&lt;/html&gt;</font>&quot;;         <br />        <br />appointment.Body.BodyType = BodyType.HTML;         <br />appointment.Start = DateTime.Now.AddDays(1);         <br />appointment.End = appointment.Start.AddHours(2);         <br />appointment.Location = &quot;Conference Room&quot;;         <br />appointment.RequiredAttendees.Add(&quot;recipient@domain.com&quot;);</font></p>    <p><font color="#c0504d"><strong><font style="background-color: #ffffff"><font color="#000000">//Here, we pretend that it's recurring... Though the number of occurrences is just 1!</font>             <br />appointment.Recurrence = new Recurrence.DailyPattern(appointment.Start, 1);             <br />appointment.Recurrence.NumberOfOccurrences = 1;</font></strong></font></p>    <p><font color="#c0504d">appointment.Save(SendInvitationsMode.SendToAllAndSaveCopy);</font>       <br /></p> </blockquote>  <p>&#160;</p>  <p>The only catch is that Outlook would be telling you that the meeting item is recurring, when it really isn’t. And that’s where you figure out which of the 2 options suits you better.</p>  <p>Cheers!</p>]]></content:encoded>
    </item>
    <item>
      <title>CreateItemFromTemplate()… Importing MSG’s… Where did my UserProperties go?</title>
      <link>https://docs.microsoft.com/archive/blogs/dhruvkh/createitemfromtemplate-importing-msgs-where-did-my-userproperties-go</link>
      <pubDate>Tue, 15 May 2012 07:53:00 GMT</pubDate>
      <dc:creator><![CDATA[Dhruv Khattar]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhruvkh/2012/05/15/createitemfromtemplate-importing-msgs-where-did-my-userproperties-go/</guid>
      <description><![CDATA[&#160;  A known behavior of Outlook and the Object Model (documented in this KB) is that if you...]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p>A known behavior of Outlook and the Object Model (<a href="https://support.microsoft.com/kb/907985" target="_blank">documented in this KB</a>) is that if you import an Outlook item into your mailbox or a PST from an MSG file, either by dragging and dropping, or through the CreateItemFromTemplate() (<a href="https://msdn.microsoft.com/en-us/library/aa220081%28v=office.11%29.aspx" target="_blank">documentation</a>) OOM call, it’s pretty much a known fact that you would find the UserProperties collection (<a href="https://msdn.microsoft.com/en-us/library/aa211095%28v=office.11%29.aspx" target="_blank">documentation</a>) of the item to be empty, in spite of however many entries may have been contained within it beforehand.</p>  <p>The UserProperties collection can be extremely useful to organizations which have customized their forms to store user-specific information under the hood. Thus, one would definitely not want to find it completely empty, right?</p>  <p>The good news is that when you export an item into an MSG or an OFT file, those UserProperties entries aren’t deleted. Nor are they disposed of when you import that item back into your mailbox. To be able to read those properties back into your items, you can make use of an extremely nifty object called PropertyAccessor, that allows you to read properties that aren’t directly exposed by the Object Model. (The PropertyAccessor object is available only Outlook 2007 onwards, hence consider that one very small part of a ton of excellent reasons to upgrade from prior versions of Office to Office 2010!)</p>  <p>Assuming that you’ve created the Mail Item and assigned it to a variable called oMail, your code would look something like…    <br /></p>  <blockquote>   <pre><code><font color="#c0504d">Dim myOlApp As Outlook.Application
Dim MyItem As Outlook.MailItem<br />Dim propName, propValue As String<br />Dim oPA As Outlook.PropertyAccessor<br />
Set myOlApp = CreateObject(&quot;Outlook.Application&quot;)<br /><br /><br /></font></code><code><br /><br /><font color="#c0504d">Set oMail = myOlApp.<b>CreateItemFromTemplate</b>(&quot;C:\SampleMailItem.oft&quot;,  _
            myOlApp.Session.GetDefaultFolder(olFolderInbox))</font><br /><font color="#0000ff">'Get a Reference to the PropertyAccessor object</font><br /></code><code><font color="#c0504d">Set oPA = oMail.PropertyAccessor</font><br /><font color="#0000ff">'Call GetProperty</font><br /><font color="#c0504d">propName = “CustomProperty1”
propValue = oPA.GetProperty(PropName)</font></code></pre>
</blockquote>

<pre><code></code></pre>

<pre><code>And lo behold, we’re in business!</code></pre>]]></content:encoded>
    </item>
    <item>
      <title>Outlook Ribbon woes on performing “Send As E-Mail” via other Office 2010 Apps</title>
      <link>https://docs.microsoft.com/archive/blogs/dhruvkh/outlook-ribbon-woes-on-performing-send-as-e-mail-via-other-office-2010-apps</link>
      <pubDate>Mon, 14 May 2012 10:25:00 GMT</pubDate>
      <dc:creator><![CDATA[Dhruv Khattar]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhruvkh/2012/05/14/outlook-ribbon-woes-on-performing-send-as-e-mail-via-other-office-2010-apps/</guid>
      <description><![CDATA[&#160;  When we introduced ribbons&#160; in various Office applications with Office 2007 (and...]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p>When we introduced ribbons&#160; in various Office applications with Office 2007 (and expanded it further in 2010), we also brought to you a quick and easy GUI tool, called the Ribbon Designer, to help you design your custom ribbons via Visual Studio, in a manner in which WYSIWYG.</p>  <p>Unfortunately, come Office 2010, as far as the Ribbon Designer is concerned,in very specific scenario, WYS is not always WYG.</p>  <p>I can’t emphasize that the scenario is indeed very specific, and if you find your users encountering it, this blog is just right for you!</p>  <p>Let’s assume your users tend to do quite a bit of e-mailing, hence Outlook is almost always running in the background. Let’s also assume that they work a lot with Excel or Word documents, and tend to email them out directly from within Excel/Word by navigating to “File –&gt; Save &amp; Send –&gt; Send As Attachment”. Finally, let’s assume that you’ve customized the ribbon of the Outlook Compose inspector (i.e. Microsoft.Outlook.Mail.Compose) and have used the Ribbon Designer to accomplish this purpose.</p>  <p>Given that all of the above assumptions are true, i.e. while Outlook is running in the background, a user creates a new Excel/Word document, then tries to email it through File-&gt;Save&amp;Send-&gt;SendAsAttachment and you’ve customized the compose editor ribbon, your user will tragically find that on trying to Save the document after e-mailing it out, the Save/SaveAs dialog box is lost somewhere behind the Word/Excel document window, and quite inaccessible (until you navigate to Start –&gt; Run –&gt; Outlook /reportleakedrenitems) which somehow exorcises the ghost that is suppressing that Save/SaveAs dialog window.</p>  <p>The short version of the story is that this is due to a known issue with ribbons designed using the Ribbon Designer. (You won’t encounter the issue if your ribbon isn’t customized, in which case you can close this webpage and move on to something more interesting).   <br />    <br />The long version of the story is that this is our unusual way of introducing you to the beauty of…</p>  <p><font size="3"><em>RibbonXML!</em></font></p>  <p><em><font size="3"></font></em>    <br />Or in more sober terms, the easiest way for you to avoiding this issue is exporting your custom ribbon to use RibbonXML.</p>  <p>One could write pages about how RibbonXML gives you more control over the appearance, functionality and flexibility you can exercise with your custom ribbon. In fact, we’ve written a few pages on it over here: <a title="https://msdn.microsoft.com/en-us/library/bb386097(v=vs.90).aspx" href="https://msdn.microsoft.com/en-us/library/bb386097(v=vs.90).aspx">https://msdn.microsoft.com/en-us/library/bb386097(v=vs.90).aspx</a></p>  <p>Additionally, we’ve also done our best to to make this transition from Ribbon Designer to RibbonXML by publishing this article to get you kick-started: <a title="https://msdn.microsoft.com/en-us/library/bb386297(v=vs.90).aspx" href="https://msdn.microsoft.com/en-us/library/bb386297(v=vs.90).aspx">https://msdn.microsoft.com/en-us/library/bb386297(v=vs.90).aspx</a></p>  <p>The bigger challenge is understanding how RibbonXML works. Naturally, this article would perform the job to some extent for you:<a title="https://msdn.microsoft.com/en-us/library/aa942866(v=vs.90).aspx" href="https://msdn.microsoft.com/en-us/library/aa942866(v=vs.90).aspx">https://msdn.microsoft.com/en-us/library/aa942866(v=vs.90).aspx</a></p>  <p>To compare the 2 in a nutshell though, when you dump the Ribbon Designer in favour of the super-fabulous RibbonXML, you’ll find that every entity in the RibbonXML (buttons, toggle buttons, groups, tabs, check-boxes, drop-down boxes etc.) comes with its own set of attributes. Each of these attributes allows you to determine its appearance and behavior… whether it’s visible/invisible, enabled/disabled, or what happens when you perform an associated action.   <br /></p>  <p>   <br />For instance, you have the option of pre-defining whether an element is visible at all times, i.e.    <br />    <br /><font color="#c0504d">&lt;tab id=”New Tab” visible=true /&gt;</font>    <br />    <br />or whether you want an element to be either visible or invisible depending on a certain condition which may change dynamically, i.e.    <br />    <br /><font color="#c0504d">&lt;tab id=”New Tab” getVisible=”getElementVisibility” /&gt;</font>    <br /></p>  <p>and subsequently define the corresponding callback as such:</p>  <blockquote>   <p><font color="#c0504d">bool getElementVisibility(IRibbonControl control)       <br />{</font></p>    <p><font color="#c0504d">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; if(control.Id = “New Tab”)       <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; return newTabVisible;</font></p>    <p><font color="#c0504d">}</font></p> </blockquote>  <p>   <br />There’s an excellent compilation of callbacks associated with each type of element, along with descriptions and their signatures in Part 3 of a 30part series on how to develop ribbons, accessible here: <a title="https://msdn.microsoft.com/en-us/library/aa722523%28v=office.12%29.aspx" href="https://msdn.microsoft.com/en-us/library/aa722523%28v=office.12%29.aspx">https://msdn.microsoft.com/en-us/library/aa722523%28v=office.12%29.aspx</a></p>  <p>For example, the <font color="#c0504d">onAction</font><font color="#333333"> callback is usually the most useful in executing logic that is to be triggered when a certain control is modified. Similarly, the <font color="#c0504d">getSelectedItemId</font> and <font color="#c0504d">getSelectedItemIndex</font> callbacks come in handy for determining the selected value in a drop-down box.</font></p>  <p>The trickier part can be to dynamically modify the contents of a Combo Box/DropDown list, but the <font color="#c0504d">getItemCount</font>, <font color="#c0504d">getItemLabel</font> and <font color="#c0504d">getItemId</font> callbacks can come in handy here, although one must remember to call the <font color="#c0504d">Invalidate()</font> method on the ribbon (or the <font color="#c0504d">InvalidateControl(ctrl.Id)</font> method on a specific control) for those changes to reflect.</p>  <p>Another excellent resource to read if you’re creating a Ribbon that should change depending on user action/input, or be dependent on any other factors can be found here: <a title="https://msdn.microsoft.com/en-us/library/dd548010%28v=office.12%29.aspx" href="https://msdn.microsoft.com/en-us/library/dd548010%28v=office.12%29.aspx">https://msdn.microsoft.com/en-us/library/dd548010%28v=office.12%29.aspx</a>    <br />Although written around programming for Access, it’s a great way to learn concepts.</p>  <p>Delay not further in ridding yourself of Visual Designer limitations and discovering the versatility and sheer power of RibbonXML programming! Dive write in and enjoy the power of customization!</p>  <p>Until next time!</p>]]></content:encoded>
    </item>
    <item>
      <title>Automating execution of built-in Exchange 2010 PS1 Scripts through .NET</title>
      <link>https://docs.microsoft.com/archive/blogs/dhruvkh/automating-execution-of-built-in-exchange-2010-ps1-scripts-through-net</link>
      <pubDate>Tue, 08 May 2012 11:08:00 GMT</pubDate>
      <dc:creator><![CDATA[Dhruv Khattar]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhruvkh/2012/05/08/automating-execution-of-built-in-exchange-2010-ps1-scripts-through-net/</guid>
      <description><![CDATA[&#160;  Through the magic of Powershell automation that was introduced for Exchange Management, it...]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p>Through the magic of Powershell automation that was introduced for Exchange Management, it so happens that Exchange 2007 and 2010 come with quite a few built-in scripts that attempt to make your life easier, (not to forget all the custom scripts that you could write yourself, to automate tasks that are frequent to you).</p>  <p>While there are several ways of automating execution of Exchange Cmdlets through powershell (documented <a href="https://blogs.msdn.com/b/mstehle/archive/2007/01/25/outbox-introduction-to-exchange-powershell-automation-part-2.aspx" target="_blank">here</a> [<a href="https://blogs.msdn.com/b/mstehle/archive/2007/01/25/outbox-introduction-to-exchange-powershell-automation-part-2.aspx" target="_blank">link</a>] for 2007 and <a href="https://blogs.msdn.com/b/akashb/archive/2010/03/25/how-to-migrating-exchange-2007-powershell-managed-code-to-work-with-exchange-2010.aspx" target="_blank">here</a> [<a href="https://blogs.msdn.com/b/akashb/archive/2010/03/25/how-to-migrating-exchange-2007-powershell-managed-code-to-work-with-exchange-2010.aspx" target="_blank">link</a>] for 2010), there may be scenarios in which all you really want to do is execute a nifty PS1 script that runs very efficiently when executed via Powershell, and all you really need to do is figure out how to execute that PS1 script, you could possibly use <a href="https://blogs.msdn.com/b/akashb/archive/2010/03/26/how-to-call-ps1-script-from-managed-code-using-remote-powershell-exchange-2010.aspx" target="_blank">this sample</a> [<a href="https://blogs.msdn.com/b/akashb/archive/2010/03/26/how-to-call-ps1-script-from-managed-code-using-remote-powershell-exchange-2010.aspx" target="_blank">Link</a>].</p>  <p>But sometimes, as it so happens, PS1 scripts refer other resource files, and seem to be dependent on other parameters, which makes them a bit tricky to execute outside of Powershell. For instance, the RedistributeActiveDatabases.ps1 (<a href="https://technet.microsoft.com/en-us/library/dd335158.aspx" target="_blank">documentation</a>) which comes with Exchange 2010 SP1, and does a marvellous job of balancing active mailbox database copies across a Database Access Group, really only seems to work when executed directly within the context of Powershell. Coupled with the fact that quite a lot of cmdlets would be executed in a single run through the script, piping each cmdlet to a Remote Powershell runspace would cause the script to take painfully longer to complete.</p>  <p>In such circumstances, the best approach is to automate the loading of the PS1 script through powershell. But how?</p>  <p>Well, it’s quite simple, really, if we go back to the basics. All we need to do is create a process of command prompt and execute powershell.exe through it, providing it the path of the PS1 script as a parameter (appending the parameters to the script in the process), and capturing the output returned.   <br />    <br />This is how I managed to execute the elusive RedistributeActiveDatabases.ps1 script, providing my own custom DAG name, and the “ShowDatabaseDistributionByServer” switch to organize the output. In brief, the input to powershell looks something like this:</p>  <blockquote>   <pre><font color="#646b86">RedistributeActiveDatabases.ps1 -DagName DAG1 -ShowDatabaseDistributionByServer</font></pre>
</blockquote>

<p>&#160;</p>

<p>The same thing, when executed via C#, giving us the flexibility to modify the DAG name through user-input, would look like this:</p>

<blockquote>
  <p>
    <br />&#160;<font color="#c0504d">void callPS1Script(dagName)
      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; {

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; string filePath = Environment.GetEnvironmentVariable(&quot;ExchangeInstallPath&quot;) + &quot;Scripts\\RedistributeActiveDatabases.ps1&quot;;

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; string command = &quot;powershell.exe -file \&quot;&quot; + filePath + &quot;\&quot; -DagName \&quot;&quot; + dagName + &quot;\&quot; -ShowDatabaseDistributionByServer&quot;;

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; try

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Create a ProcessStartInfo object specifying &quot;cmd&quot; as the target program.

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // The switch /c tells cmd that the command that follows is to be executed

      <br />

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.Diagnostics.ProcessStartInfo objPSI = new System.Diagnostics.ProcessStartInfo(&quot;cmd&quot;, &quot;/c &quot; + command);</font></p>

  <p><font color="#c0504d">&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // This specifies that standard output will be redirected to Process.StandardOutput StreamReader.
      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; objPSI.RedirectStandardOutput = true;

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; objPSI.UseShellExecute = false;

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; objPSI.CreateNoWindow = true; //Optional: To avoid the window that comes with cmd prompt

      <br />

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Create a process, assign its ProcessStartInfo and execute

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; System.Diagnostics.Process objProc = new System.Diagnostics.Process();

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; objProc.StartInfo = objPSI;

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; objProc.Start();

      <br />&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Retrieve output

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; string objOutput = objProc.StandardOutput.ReadToEnd();

      <br />&#160; <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; // Display Output

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Console.WriteLine(objOutput);

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }

      <br />

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; catch (Exception e)

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; {

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; Console.WriteLine(e.Message);

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; }

      <br />

      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; }</font>

    <br />&#160;</p>
</blockquote>

<p>This was tried out in a ConsoleApp by me, and in an ASP.NET application by the customer I was working with, so it seems good to go. For in-built Exchange Scripts to work, you’ll naturally want Exchange Management Tools for the relevant version of Exchange Server installed.</p>

<p>Cheers!</p>]]></content:encoded>
    </item>
    <item>
      <title>The Double-Hop Dogma</title>
      <link>https://docs.microsoft.com/archive/blogs/dhruvkh/the-double-hop-dogma</link>
      <pubDate>Sun, 15 Apr 2012 23:22:00 GMT</pubDate>
      <dc:creator><![CDATA[Dhruv Khattar]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhruvkh/2012/04/15/the-double-hop-dogma/</guid>
      <description><![CDATA[If you find yourself wondering why your robustly developed, uber-comprehensive ASP.NET application,...]]></description>
      <content:encoded><![CDATA[<p>If you find yourself wondering why your robustly developed, uber-comprehensive ASP.NET application, which is supposed to dive into the Exchange mailbox of the authenticated user and leverage the very convenient and efficient Exchange Web Services (Managed API or otherwise)&nbsp;to pull out their e-mails, contacts, meetings and so on and so forth, isn&rsquo;t able to access their mailbox items&hellip; or if you&rsquo;re encountering other Exchange-related unexplainable symptoms, such as failure of Autodiscover to pull the URL of the CAS server, the truant at play might just be authentication.</p>
<p>To make sure that the Autodiscovery service is accessible from the WebServer, you could download the EWSEditor Tool (<a href="https://ewseditor.codeplex.com/">Link</a>) and use that to test Autodiscover:</p>
<p><a href="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/45/67/5582.EWSEditor%20Autodiscover.jpg" original-url="https://blogs.msdn.com/cfs-file.ashx/__key/communityserver-blogs-components-weblogfiles/00-00-01-45-67/5582.EWSEditor-Autodiscover.jpg"><img border="0" alt="" src="https://msdnshared.blob.core.windows.net/media/MSDNBlogsFS/prod.evol.blogs.msdn.com/CommunityServer.Blogs.Components.WeblogFiles/00/00/01/45/67/5582.EWSEditor%20Autodiscover.jpg" original-url="https://blogs.msdn.com/resized-image.ashx/__size/550x0/__key/communityserver-blogs-components-weblogfiles/00-00-01-45-67/5582.EWSEditor-Autodiscover.jpg" width="452" height="258" /></a></p>
<p>&nbsp;</p>
<p>Fact is that unless your credentials are passed successfully to the Exchange Server through the ExchangeService object, Autodiscover is likely to throw tantrums, even one as misleading as '&rdquo;The Autodiscover service couldn&rsquo;t be located&rdquo;. A quick way to make sure that the issue isn&rsquo;t indeed because of inavailability of Autodiscovery, is by hardcoding credentials of&nbsp;a mailbox in the ASP.NET application (for diagnostic purposes),&nbsp;and&nbsp;see whether&nbsp;autodiscover works in that scenario and mailbox items are fetched for the mailbox whose credentials are hardcoded,&nbsp;when you browse the ASP.NET application from a client machine.</p>
<p style="padding-left: 30px;">&nbsp;</p>
<p style="padding-left: 30px;"><span style="font-family: arial,helvetica,sans-serif; font-size: small;">//Original Code&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</span></p>
<p style="padding-left: 30px;"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2">ExchangeService</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"> service = </span></span><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" color="#0000ff" size="2"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" color="#0000ff" size="2"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" color="#0000ff" size="2">new</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"> </span></span><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2">ExchangeService</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2">(</span></span><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2">ExchangeVersion</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2">.Exchange2010_SP1);</span></span></p>
<p style="padding-left: 30px;"><span style="background-color: #ffff00;">service.UseDefaultCredentials = <span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" color="#0000ff" size="2"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" color="#0000ff" size="2"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" color="#0000ff" size="2">true</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2">;</span></span></span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; service.AutodiscoverUrl(<span style="color: #a31515; font-family: Consolas; font-size: x-small;" face="Consolas" color="#a31515" size="2"><span style="color: #a31515; font-family: Consolas; font-size: x-small;" face="Consolas" color="#a31515" size="2"><span style="color: #a31515; font-family: Consolas; font-size: x-small;" face="Consolas" color="#a31515" size="2">"&lt;sampleMailbox@domain.com&gt;"</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2">);</span></span></p>
<p style="padding-left: 30px;"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"></span></span></span></span>&nbsp;</p>
<p style="padding-left: 30px;"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"></span></span></span></span><span style="font-family: arial,helvetica,sans-serif; font-size: small;" face="Consolas" size="1">//Diagnostic Code</span></p>
<p style="padding-left: 30px;"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2">ExchangeService</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"> service = </span></span><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" color="#0000ff" size="2"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" color="#0000ff" size="2"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" color="#0000ff" size="2">new</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"> </span></span><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2">ExchangeService</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2">(</span></span><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2">ExchangeVersion</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2">.Exchange2010_SP1);</span></span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; <span style="background-color: #ffff00;">service.Credentials = <span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" color="#0000ff" size="2"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" color="#0000ff" size="2"><span style="color: #0000ff; font-family: Consolas; font-size: x-small;" face="Consolas" color="#0000ff" size="2">new</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"> </span></span><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2"><span style="color: #2b91af; font-family: Consolas; font-size: x-small;" face="Consolas" color="#2b91af" size="2">WebCredentials</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2">(</span></span><span style="color: #a31515; font-family: Consolas; font-size: x-small;" face="Consolas" color="#a31515" size="2"><span style="color: #a31515; font-family: Consolas; font-size: x-small;" face="Consolas" color="#a31515" size="2"><span style="color: #a31515; font-family: Consolas; font-size: x-small;" face="Consolas" color="#a31515" size="2">"&lt;sampleMailbox&gt;"</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2">, </span></span><span style="color: #a31515; font-family: Consolas; font-size: x-small;" face="Consolas" color="#a31515" size="2"><span style="color: #a31515; font-family: Consolas; font-size: x-small;" face="Consolas" color="#a31515" size="2"><span style="color: #a31515; font-family: Consolas; font-size: x-small;" face="Consolas" color="#a31515" size="2">"&lt;password&gt;"</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2">, </span></span><span style="color: #a31515; font-family: Consolas; font-size: x-small;" face="Consolas" color="#a31515" size="2"><span style="color: #a31515; font-family: Consolas; font-size: x-small;" face="Consolas" color="#a31515" size="2"><span style="color: #a31515; font-family: Consolas; font-size: x-small;" face="Consolas" color="#a31515" size="2">"&lt;domain&gt;"</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2">);</span></span></span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; service.AutodiscoverUrl(<span style="color: #a31515; font-family: Consolas; font-size: x-small;" face="Consolas" color="#a31515" size="2"><span style="color: #a31515; font-family: Consolas; font-size: x-small;" face="Consolas" color="#a31515" size="2"><span style="color: #a31515; font-family: Consolas; font-size: x-small;" face="Consolas" color="#a31515" size="2">"&lt;sampleMailbox@domain.com&gt;"</span></span></span><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2"><span style="font-family: Consolas; font-size: x-small;" face="Consolas" size="2">);</span></span></p>
<p>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</p>
<p></p>
<p>So the obvious question is&hellip; what are we doing wrong? The IIS application&nbsp;should be&nbsp;running under the identity of the logged on user and ought to be passing his/her credentials onwards to Exchange to fetch his mailbox items via EWS, right?</p>
<p>Ideally, yes. (And in this context, the ideal isn&rsquo;t impossible to achieve).</p>
<p>What we&rsquo;re observing here is a double-hop scenario. The user who&rsquo;s browsing the application from a client machine passes his credentials to the IIS server, i.e. the credentials of the user hop from the client to the IIS server. Subsequent to that, when the IIS application executes EWS calls, it is supposed to pass those same credentials to the Exchange server, to authenticate the logged on user. This works fine in the ideal scenario, and falters in alternative scenarios.</p>
<p><strong>Ideal scenario</strong>: Kerberos authentication method is being used within the organization&nbsp;<br /><strong>Frequent Scenarios</strong>: The non-ideal scenario is not being observed, i.e. NTLM might be the active authentication mechanism, or Kerberos&nbsp;could be&nbsp;failing and the application falls back on attempting authentication via NTLM which would eventually fail in a double-hop situation.</p>
<p>&nbsp;</p>
<p><span style="font-size: medium;"><strong>Here are the&nbsp;action items that&nbsp;you'd have to&nbsp;implement to allow end-to-end authentication in this context (i.e. they ought to be comprehensive for most scenarios):</strong></span>&nbsp;</p>
<p style="padding-left: 30px;"><br />1. Enable your ASP.NET application&nbsp;to use&nbsp;Kerberos ("Negotiate") authentication, along with NTLM: <a href="https://support.microsoft.com/kb/215383">https://support.microsoft.com/kb/215383</a></p>
<p style="padding-left: 30px;">2. Additionally, ensure that the ASP.NET application is allowed to impersonate: <a href="https://support.microsoft.com/kb/306158">https://support.microsoft.com/kb/306158</a></p>
<p style="padding-left: 30px;">3. Enable Kerberos authentication on your Exchange Client Access Servers: <a href="https://technet.microsoft.com/en-us/library/ff808312.aspx">https://technet.microsoft.com/en-us/library/ff808312.aspx<br /></a>&nbsp;&nbsp;&nbsp;&nbsp;For this specific step, relevant SPN's need to be set for the services involved. However, presence of duplicate SPN's can disrupt access to the service, and this step should be executed carefully, involving Microsoft Support if required. (<a href="https://blogs.technet.com/b/askds/archive/2008/06/09/kerberos-authentication-problems-service-principal-name-spn-issues-part-2.aspx">https://blogs.technet.com/b/askds/archive/2008/06/09/kerberos-authentication-problems-service-principal-name-spn-issues-part-2.aspx)</a></p>
<p style="padding-left: 30px;">4. Enable the&nbsp;Service Account&nbsp;configured for&nbsp;the&nbsp;AppPool your ASP.NET application&nbsp;is running under, for Delegation: <a href="https://technet.microsoft.com/en-us/library/cc784032(v=ws.10">https://technet.microsoft.com/en-us/library/cc784032(v=ws.10</a>) (Similar steps need to be followed for Windows Server 2008 and 2008 R2).<br />Factor to consider... General Delegation vs. Constrained Delegation: <a href="https://blogs.technet.com/b/askds/archive/2008/06/13/understanding-kerberos-double-hop.aspx">https://blogs.technet.com/b/askds/archive/2008/06/13/understanding-kerberos-double-hop.aspx</a></p>
<p>&nbsp;</p>
<p>The entire process is rather complex, and would require collaboration from your application developers, Exchange Admins and Admins who manage Active Directory and the Application Server.<br />If you feel the need to reach out to Microsoft Support to address this issue, be sure to quote this article so that we can assist you in an efficient manner.</p>
<p>&nbsp;&nbsp;</p>
<p>Cheerio!</p>]]></content:encoded>
    </item>
    <item>
      <title>Breaking your ahead against Outlook URL’s post Outlook 2003?</title>
      <link>https://docs.microsoft.com/archive/blogs/dhruvkh/breaking-your-ahead-against-outlook-urls-post-outlook-2003</link>
      <pubDate>Thu, 12 Apr 2012 06:54:00 GMT</pubDate>
      <dc:creator><![CDATA[Dhruv Khattar]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhruvkh/2012/04/12/breaking-your-ahead-against-outlook-urls-post-outlook-2003/</guid>
      <description><![CDATA[&#160;  So back in 2003, when we introduced the world to Outlook 2003, there was a nifty feature...]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p>So back in 2003, when we introduced the world to Outlook 2003, there was a nifty feature that allowed you to create hyperlinks that you could type into your Internet Explorer Address bar, and it would launch Outlook and take you to a specific folder (or mail item or such and such).</p>  <p>Come Outlook 2007, we were a little more concerned about the security of our Office products, and in an attempt to prevent unauthorized access by all those risky applications out there, we semi-limited the facility to use those hyperlinks to navigate to your favourite items at the drop of a hat.   <br />    <br />I say “semi-limited” because we didn’t take it away altogether. We took it away to some extent because, lets face it, it wasn’t the most popular feature of Outlook and not used by so many. However, we didn’t take it away altogether because we really don’t want to deny our customers something that once was.</p>  <p>So if you’re really keen on wanting to click on a hyper-link that looks like this:</p>  <blockquote>   <p><font color="#0000ff">Outlook:Inbox</font></p> </blockquote>  <p>which takes you to your Inbox when you click on it, or a more hardcore</p>  <blockquote>   <p><font color="#0000ff">outlook:0000000089D557774599D7468A4A47E129F996EF07005818FE9CC903F8418B813D98D476……………</font></p> </blockquote>  <p>which opens the item associated with that particular identifier, all you have to do is register a custom URL protocol on your machine.</p>  <p>   <br />You can figure out how to register an application (any application… could be one of your own) to a URL protocol over here: <a title="https://msdn.microsoft.com/en-us/library/aa767914%28v=vs.85%29.aspx" href="https://msdn.microsoft.com/en-us/library/aa767914%28v=vs.85%29.aspx">https://msdn.microsoft.com/en-us/library/aa767914%28v=vs.85%29.aspx</a></p>  <p>To make it even simpler for you all (as I always like to do), this is what it would look like on an Outlook 2010 machine running on a 64-bit OS:</p>  <blockquote>   <p><font color="#c0504d">[HKEY_CLASSES_ROOT\outlook]</font></p>    <p><font color="#c0504d">@=&quot;URL:Outlook&quot;</font></p>    <p><font color="#c0504d">&quot;URL Protocol&quot;=&quot;&quot;</font></p>    <p><font color="#c0504d">[HKEY_CLASSES_ROOT\outlook\DefaultIcon]</font></p>    <p><font color="#c0504d">@=&quot;\&quot;C:\\Program Files (x86)\\Microsoft Office\\Office14\\Outlook.exe\&quot;&quot;</font></p>    <p><font color="#c0504d">[HKEY_CLASSES_ROOT\outlook\shell]</font></p>    <p><font color="#c0504d">@=&quot;open&quot;</font></p>    <p><font color="#c0504d">[HKEY_CLASSES_ROOT\outlook\shell\open]</font></p>    <p><font color="#c0504d">[HKEY_CLASSES_ROOT\outlook\shell\open\command]</font></p>    <p><font color="#c0504d">@=&quot;\&quot;C:\\Program Files (x86)\\Microsoft Office\\Office14\\Outlook.exe\&quot; /select \&quot;%1\&quot;&quot;</font></p> </blockquote>  <p>&#160;</p>  <p>To use that against Outlook 2007, the path to Outlook.exe would contain Outlook12 instead of Outlook14, and if you’re on a 32-bit OS, then… well, you know the drill.</p>  <p>Do be wary of the Security dialogs you’ll have to handle once you click on the URL… after all, application security is supreme and we don’t want a malicious application going ahead and deleting all your valuable (or not so valuable) communication, no do we!</p>  <p>Happy Developing, folks!</p>]]></content:encoded>
    </item>
    <item>
      <title>Working with Tasks using Exchange Web Services</title>
      <link>https://docs.microsoft.com/archive/blogs/dhruvkh/working-with-tasks-using-exchange-web-services</link>
      <pubDate>Fri, 06 Apr 2012 06:20:00 GMT</pubDate>
      <dc:creator><![CDATA[Dhruv Khattar]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhruvkh/2012/04/06/working-with-tasks-using-exchange-web-services/</guid>
      <description><![CDATA[&#160;  An integral part of Outlook from its very initial version, Outlook Tasks were always...]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p>An integral part of Outlook from its very initial version, Outlook Tasks were always intended to remain that way… an integral part of Outlook. They were not, on the other hand, intended to serve the purposes that they tend to be used for, today.</p>  <p>Outlook Tasks were introduced to give users a cute and nifty tool meant for time management and tracking their personal To-Do items within their favorite Mail client. What Outlook Tasks were not intended to do were to become the core of large-scale Task Management deployments spanning across several corporate offices, office locations, hundreds or thousands of employees and what not. It is possibly for that reason that Tasks weren’t given a lot of priority as far as Server-Side programming API’s were concerned. To be more specific, pre-Exchange 2007, Tasks were given no priority in server-side programming, since they were after all intended to be for personal use by users to plan their day, create Follow-Up alerts, track their activities and so on. Prior to Exchange 2007, all of the Exchange programming API’s concerned Mail, calendaring, contact-management and administrative mailbox management.</p>  <p>The reality, however, is that over time, we would come across customers designing applications that needed to programmatically create Tasks across several mailboxes through code, but could not find API’s that would support the requirement. Hence, when Exchange 2007 came into the picture and we started trying to integrate and build more and more of Exchange-side programming tasks into Exchange Web Services, I suppose it wasn’t the worst thing that we added a bit of love for Task Items! We went to the extent of exposing methods to Create, Read, Modify and Delete task items directly in/from a folder, managing several attributes including Recurrence. The list of members (properties, methods) can be found here: <a title="https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.task_members%28v=exchg.80%29.aspx" href="https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.task_members%28v=exchg.80%29.aspx">https://msdn.microsoft.com/en-us/library/microsoft.exchange.webservices.data.task_members%28v=exchg.80%29.aspx</a></p>  <p>However, what we didn’t include was the option of assigning tasks, reporting and all that jazz since, as I mentioned a while ago, they were never intended to be part of gigantic server-side automated applications. Hence, customers often approach us looking for options to create Tasks across multiple mailboxes using the same application without having the credentials to each of them at hand.</p>  <p>Now creating, updating Task Items isn’t very difficult through EWS. You can find find code samples to do it using the Proxy Reference over here:</p>  <p>Creating Tasks: <a title="https://msdn.microsoft.com/en-us/library/aa563029%28v=exchg.80%29.aspx" href="https://msdn.microsoft.com/en-us/library/aa563029%28v=exchg.80%29.aspx">https://msdn.microsoft.com/en-us/library/aa563029%28v=exchg.80%29.aspx</a>     <br />Updating Tasks: <a title="https://msdn.microsoft.com/en-us/library/aa563020%28v=exchg.80%29.aspx" href="https://msdn.microsoft.com/en-us/library/aa563020%28v=exchg.80%29.aspx">https://msdn.microsoft.com/en-us/library/aa563020%28v=exchg.80%29.aspx</a>     <br />Deleting Tasks: <a title="https://msdn.microsoft.com/en-us/library/aa493936%28v=exchg.80%29.aspx" href="https://msdn.microsoft.com/en-us/library/aa493936%28v=exchg.80%29.aspx">https://msdn.microsoft.com/en-us/library/aa493936%28v=exchg.80%29.aspx</a></p>  <p>Using the EWS Managed API makes it even simpler, reducing your code to but a few lines:</p>  <blockquote>   <p>     <br /><font style="style" color="#800000" size="2" face="Arial">Task taskItem = new Task(exchangeService);        <br />taskItem.Subject = &quot;Monthly Review&quot;;         <br />taskItem.Body = new MessageBody(&quot;Monthly Review from 11th to 20th&quot;);         <br />taskItem.StartDate = new DateTime(2012, 04, 11, 10, 00, 00);         <br />taskItem.DueDate = new DateTime(2012, 04, 20, 10, 00, 00);         <br />taskItem.Recurrence = new Recurrence.MonthlyPattern(new DateTime(2012, 04, 11, 10, 0, 0), 1, 11);         <br />taskItem.Recurrence.StartDate = new DateTime(2012, 04, 11, 10, 0, 0);         <br />taskItem.Recurrence.NumberOfOccurrences = 5;</font></p> </blockquote>  <blockquote>   <p><font style="style" color="#800000" size="2" face="Arial">taskItem.Save();</font></p> </blockquote>  <p>&#160;</p>  <p>This code is only any good as long as you are creating the Task within the Tasks folder of the user whose credentials the ExchangeService object is configured with. What if one needs to use Tasks to implement details of organizational workflow, to track collaboration on action items with colleagues and numerous other scenarios that you find yourself using Tasks for, apart from creating them in your Outlook to manage your day?</p>  <p>Well, the obvious answer to that is to look to use Sharepoint. The best advantage of using Sharepoint is that it’s meant for these purposes, integrates well with Outlook, stores data in centralized databases (instead of scattering them across Databases) and allows you so much more freedom to customize the workflow (although most of the useful functionalities could be found out-of-the-box).</p>  <p>However, for those who insist on having their EWS app creating Task items across various mailboxes, they find themselves using any of the following workarounds…</p>  <p><strong>1.</strong> The first Workaround is to use the credentials of a Service Account that has impersonation rights on the user whose mailbox you need to create the Task items in, or on the mailbox database in which it’s present.</p>  <p>Naturally, the Service Account would have the freedom to not only create Tasks within the Task folder, but to create items within any folder, not to forget the ability to read, modify and delete items within the entire mailbox. Hence, the credentials of such a Service Account is as sensitive as the credentials of your organization’s Administrator, and should be treated that way. Nonetheless, Impersonation is a very popular concept (in EWS… and otherwise, I’m sure) used by developers all over.    <br />You can read more about how to Impersonate over here: <a title="https://msdn.microsoft.com/en-us/library/dd633680%28v=exchg.80%29.aspx" href="https://msdn.microsoft.com/en-us/library/dd633680%28v=exchg.80%29.aspx">https://msdn.microsoft.com/en-us/library/dd633680%28v=exchg.80%29.aspx</a></p>  <p><strong>2.</strong> The second option, which allows us to limit the reach of a designated Service Account to just the Tasks folder of the target mailboxes, is through Delegation.</p>  <p>Suitable as it may sound, delegation comes with additional work. The Service Account would have to be added as a Delegate to <em>each </em>of the target mailboxes.</p>  <p>If the Delegate has to be added to only a few mailboxes, you could keep it simple and provision it through the Outlook UI: <a title="https://office.microsoft.com/en-us/outlook-help/allow-someone-else-to-manage-your-mail-and-calendar-HA010075081.aspx" href="https://office.microsoft.com/en-us/outlook-help/allow-someone-else-to-manage-your-mail-and-calendar-HA010075081.aspx">https://office.microsoft.com/en-us/outlook-help/allow-someone-else-to-manage-your-mail-and-calendar-HA010075081.aspx</a></p>  <p>If the Delegate has to be given permissions on the Tasks folder of many users, you might want consider automating the process using EWS: <a href="https://msdn.microsoft.com/en-us/library/dd633621%28v=exchg.80%29.aspx">https://msdn.microsoft.com/en-us/library/dd633621%28v=exchg.80%29.aspx</a></p>  <p>If more users are added to the Exchange Server in the future, and the Delegator needs permissions to create Tasks within their Tasks folder as well, permissions would have to be given additionally. This distinguishes it from Impersonation in which the Service Account could be given Impersonation rights on an entire mailbox database, and would have those permissions on any mailbox added to the same database afterwards.</p>  <p>Heading back to the EWS implementation, with Delegate Permissions in place, instead of simply Saving the created taskItem, one would have to specify where to save it, i.e.,</p>  <blockquote>   <p><font color="#800000" size="2" face="Arial">taskItem.Save();</font></p> </blockquote>  <p>would become</p>  <blockquote>   <p><font color="#800000" size="2" face="Arial">taskItem.Save(new FolderId(WellKnownFolderName.Tasks, &quot;targetMailbox@domain.com&quot;);</font></p> </blockquote>  <p>&#160;</p>  <p><strong>What if we’re not on Exchange 2007 or higher?</strong></p>  <p>Well then, we’re evidently missing out on a lot of excellent innovation in Messaging Technology, aren’t we? Keeping in mind that Exchange Server 2003 completes 10 years next year (which is <em>quite</em> a lot in technology), it might be a tad unreasonable to expect too much from it.</p>  <p>Also, there are numerous new products that have developed strongly over the last few years, such as Sharepoint, Dynamics CRM that provide functionality out-of-the-box that developers try to achieve through Outlook, and a lot more.</p>  <p>The Outlook Object Model does expose a lot of functionality (as it has always done) for working with Task items (which makes sense since it’s a Client-Side programming API). One must keep in mind though that server-side automation of OOM is of course unsupported and thoroughly advised against: <a title="https://support.microsoft.com/kb/257757" href="https://support.microsoft.com/kb/257757">https://support.microsoft.com/kb/257757</a></p>]]></content:encoded>
    </item>
    <item>
      <title>The request failed schema validation… But why?</title>
      <link>https://docs.microsoft.com/archive/blogs/dhruvkh/the-request-failed-schema-validation-but-why</link>
      <pubDate>Tue, 18 Oct 2011 15:20:43 GMT</pubDate>
      <dc:creator><![CDATA[Dhruv Khattar]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhruvkh/2011/10/18/the-request-failed-schema-validation-but-why/</guid>
      <description><![CDATA[If you’re particularly proud of your (XML) writing skills or happen to be one of the...]]></description>
      <content:encoded><![CDATA[<p>   <br />    <br />If you’re particularly proud of your (XML) writing skills or happen to be one of the adventurous sorts who likes to speak to Exchange Web Services using your own SOAP requests, you might encounter a situation or two in which you stumble upon the error when (as always) you’re least expecting it…    <br />    <br />    <br /></p>  <blockquote>   <p>The request failed schema validation: The element &lt;<font color="#d16349">CalendarItem/Contact/…</font>&gt; in namespace '<a href="https://schemas.microsoft.com/exchange/services/2006/types%27">https://schemas.microsoft.com/exchange/services/2006/types'</a> has invalid child element '<font color="#d16349">ReminderMinutesBeforeStart/ExtendedProperty/…</font>' in namespace '<a href="https://schemas.microsoft.com/exchange/services/2006/types%27">https://schemas.microsoft.com/exchange/services/2006/types'</a>. List of possible elements expected: <font color="#c0504d">&lt;List of elements related to your <font color="#d16349">ItemType</font>&gt;</font> in namespace&#160; 'https://schemas.microsoft.com/exchange/services/2006/types'.      <br />      <br /><em><font color="#d16349"><font size="1">*Text in this colour may vary from one situation to anothe</font>r</font></em></p> </blockquote>  <p>   <br />    <br /></p>  <p>Let’s say this was the request that you had sent:</p>  <blockquote>   <p>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;     <br />&lt;soap:Envelope xmlns:t=&quot;<a href="https://schemas.microsoft.com/exchange/services/2006/types&quot;">https://schemas.microsoft.com/exchange/services/2006/types&quot;</a> xmlns:soap=&quot;<a href="https://schemas.xmlsoap.org/soap/envelope/&quot;">https://schemas.xmlsoap.org/soap/envelope/&quot;</a>&gt;      <br />&#160; &lt;soap:Body&gt;      <br />&#160;&#160;&#160; &lt;m:CreateItem MessageDisposition=&quot;SendOnly&quot;&gt;      <br />&#160;&#160;&#160;&#160;&#160; &lt;m:Items&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;t:Message&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;t:ToRecipients&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;t:Mailbox&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;t:EmailAddress&gt;user1@org1.com&lt;/t:EmailAddress&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/t:Mailbox&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;t:Mailbox&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;t:EmailAddress&gt;user2@org2.com&lt;/t:EmailAddress&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/t:Mailbox&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/t:ToRecipients&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;t:Subject&gt;Subject of Email&lt;/t:Subject&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;t:Body BodyType=&quot;HTML&quot;&gt;This is the Body&lt;/t:Body&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/t:Message&gt;      <br />&#160;&#160;&#160;&#160;&#160; &lt;/m:Items&gt;      <br />&#160;&#160;&#160; &lt;/m:CreateItem&gt;      <br />&#160; &lt;/soap:Body&gt;      <br />&lt;/soap:Envelope&gt;      <br /></p> </blockquote>  <p>and the response you received wasn’t quite the CreateItemResponse with the blissful “NoError” Response Code but instead a&#160; “The request failed schema validation”…</p>  <p>If you were to attempt performing the same action but leveraging an API such as the <a href="https://msdn.microsoft.com/en-us/library/dd633710(v=EXCHG.80).aspx">Exchange Web Services Managed API</a>, you’d find a very similar looking call generated.</p>  <blockquote>   <p>&lt;?xml version=&quot;1.0&quot; encoding=&quot;utf-8&quot;?&gt;     <br />&lt;soap:Envelope xmlns:xsi=&quot;<a href="https://www.w3.org/2001/XMLSchema-instance&quot;">https://www.w3.org/2001/XMLSchema-instance&quot;</a> xmlns:m=&quot;<a href="https://schemas.microsoft.com/exchange/services/2006/messages&quot;">https://schemas.microsoft.com/exchange/services/2006/messages&quot;</a> xmlns:t=&quot;<a href="https://schemas.microsoft.com/exchange/services/2006/types&quot;">https://schemas.microsoft.com/exchange/services/2006/types&quot;</a> xmlns:soap=&quot;<a href="https://schemas.xmlsoap.org/soap/envelope/&quot;">https://schemas.xmlsoap.org/soap/envelope/&quot;</a>&gt;      <br />&#160; &lt;soap:Body&gt;      <br />&#160;&#160;&#160; &lt;m:CreateItem MessageDisposition=&quot;SendOnly&quot;&gt;      <br />&#160;&#160;&#160;&#160;&#160; &lt;m:Items&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;t:Message&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;t:Subject&gt;Subject of Email&lt;/t:Subject&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;t:Body BodyType=&quot;HTML&quot;&gt;This is the Body&lt;/t:Body&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;t:ToRecipients&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;t:Mailbox&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;t:EmailAddress&gt;user1@org1.com&lt;/t:EmailAddress&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/t:Mailbox&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;t:Mailbox&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;t:EmailAddress&gt;user2@org2.com&lt;/t:EmailAddress&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/t:Mailbox&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/t:ToRecipients&gt;      <br />&#160;&#160;&#160;&#160;&#160;&#160;&#160; &lt;/t:Message&gt;      <br />&#160;&#160;&#160;&#160;&#160; &lt;/m:Items&gt;      <br />&#160;&#160;&#160; &lt;/m:CreateItem&gt;      <br />&#160; &lt;/soap:Body&gt;      <br />&lt;/soap:Envelope&gt;      <br /></p> </blockquote>  <p>So what’s different, really? The answer is hidden in the subtlety of the ordering of the elements in your call. Specifically, whereas in the manually authored XML request, we specified our elements of choice in the sequence ToRecipients, Subject and Body, EWS Managed API decided to re-order it to Subject, Body and ToRecipients.</p>  <p>So who/what is it that decides which ordering is correct and which isn’t? What happens if we decide to include other elements, such as CCRecipients, BCCRecipients, Attachments? Where do we fit them in?</p>  <p>The answer to the above question lies in… Documentation!   <br />    <br />Glance through the <a href="https://msdn.microsoft.com/en-us/library/aa494306(v=EXCHG.140).aspx" target="_blank">XML syntax for an Exchange e-mail message</a>, and you’ll find that the XML elements in XML Request 2 corresponds more closely to the ones in XML Request 1. Moreover, if you sift through the XML Response of a successful call that returns some items, you’ll find them in the exact ordering as in the documentation.</p>  <p>You can find the orderings for <a href="https://msdn.microsoft.com/en-us/library/aa581315(v=EXCHG.140).aspx" target="_blank">Contact</a>, <a href="https://msdn.microsoft.com/en-us/library/aa564765(v=EXCHG.140).aspx" target="_blank">Calendar Items</a>, <a href="https://msdn.microsoft.com/en-us/library/aa563930(v=EXCHG.140).aspx" target="_blank">Task</a> and many more in the MSDN documentation.</p>  <p>So should you come across this error message, fret not. The solution is as simple as 1 – 2 – 3 (instead of 1 – 3 – 2 or 2 – 1 – 3 or… well, you get the idea…)</p>  <p>Cheers!</p>]]></content:encoded>
    </item>
    <item>
      <title>Impersonation in the times of RBAC</title>
      <link>https://docs.microsoft.com/archive/blogs/dhruvkh/impersonation-in-the-times-of-rbac</link>
      <pubDate>Tue, 18 Oct 2011 13:41:47 GMT</pubDate>
      <dc:creator><![CDATA[Dhruv Khattar]]></dc:creator>
      <guid
        isPermaLink="false">https://blogs.msdn.microsoft.com/dhruvkh/2011/10/18/impersonation-in-the-times-of-rbac/</guid>
      <description><![CDATA[&#160;  So your organization migrated to Exchange Server 2010, and you thought you’d take that...]]></description>
      <content:encoded><![CDATA[<p>&#160;</p>  <p>So your organization migrated to Exchange Server 2010, and you thought you’d take that opportunity to leverage <a href="https://technet.microsoft.com/en-us/library/dd298183.aspx">Role Based Access Control</a> to limit Impersonation rights of your service account to a select set of users by creating a ManagementScope that would filtering the relevant users on the basis of, say, their membership to a Service/Distribution Group, or any other relevant filterable properties, by executing the <a href="https://msdn.microsoft.com/en-us/library/bb204095%28v=EXCHG.140%29.aspx">elementary set of cmdlets here</a>.</p>  <p>&#160;</p>  <p>So you went ahead and created a Security Group, say “Impersonated Users”, and created a Management Scope called “ImpersonationScope” to filter out all the users who are members of “Impersonated Users”, say with something like this:</p>  <blockquote>   <p>     <br /><strong>New-ManagementScope -Name:ImpersonationScope -RecipientRestrictionFilter: {MemberOfGroup -eq &quot;Impersonated Users&quot;}       <br /></strong></p> </blockquote>  <p>Then you went ahead and provisioned impersonation rights to your Service Account, say ServAccount, allowing him to impersonate all the members within the above scope, with something like this:</p>  <blockquote>   <p><strong>New-ManagementRoleAssignment –Name:impersonationAssignment –Role:ApplicationImpersonation –User:ServAccount –CustomRecipientWriteScope:ImpersonationScope</strong></p> </blockquote>  <p>&#160;</p>  <p>Then you went ahead and fired up your good old, super-reliable, tried and tested application, and lo behold, it tells you…</p>  <blockquote>   <p><strong>Message: The account does not have permission to impersonate the requested user.       <br />Type: Microsoft.Exchange.WebServices.Data.ServiceResponseException        <br />Source: Microsoft.Exchange.WebServices        <br />ErrorCode: ErrorImpersonateUserDenied        <br />ErrorMessage: The account does not have permission to impersonate the requested user.</strong></p> </blockquote>  <p>   <br />*Grrrr*! What could we possibly be doing wrong here? You go ahead and repeat the entire process, just to be very sure, but nothing helps.</p>  <p>Then you fire up your browser, and open up your favourite Search Engine, type in a random assortment of keywords, say “Impersonation Exchange 2010 RBAC Security Group Awesome Blog” and lo behold, you land up here.</p>  <p>So what exactly could we be doing wrong?</p>  <p>It so happens that in the process of enhancing the awesomeness of Exchange Server 2010 (with the uber-cool RBAC), we sort-of, kind-of didn’t configure it to completely comprehend what [Insert-Your-Equivalent-of-Security-Group-Impersonated-Users-Here] is referring to, <a href="https://blogs.technet.com/b/evand/archive/2007/02/13/using-memberof-with-recipientfilter.aspx">as documented here</a>. In light of this, umm, situation the work-around (not so much of a work-around but a rather perfectionist way of approaching it) would be to specify the Active Directory Distinguished Name of the group while creating the Management Scope (This elusive ADDN can be found through a pretty nifty tool called ADSI Edit).    <br />    <br />The revised New-ManagemetScope cmdlet would look as follows:</p>  <blockquote>   <p><strong>New-ManagementScope -Name:ImpersonationScope -RecipientRestrictionFilter: {MemberOfGroup -eq &quot;CN=Impersonated Users,CN=Users,DC=yourserver,DC=com&quot;}</strong></p> </blockquote> <strong>   <p>     <br /></p> </strong>  <p>And lo behold, it works!   <br /></p>  <p>So give it a run, and have a bit of fun.   <br />Holler in the comments if your deed isn’t done.    </p>]]></content:encoded>
    </item>
  </channel>
</rss>