How to create OWA-Uri from ItemType.ItemId?

Damir Dobric Posts

Next talks:

 

    

Follow me on Twitter: #ddobric



 

 

Archives

When working with Exchange Web Service at some point of time you will want to create the OWA-URI.
The Owa URI looks like: https://mail/owa/?ae=Item&a=Open&t=IPM.Note&id=RgAAAABew%2fP9Bu7QQo5izbUHshDuBwDeveWKhQQ4TbYfz8fgH%2b6TBVLgtiPtAADeveWKhQQ4TbYfz8fgH%2b6TBVLgtiYuAAAJ
If the service is opening the mailbox of other user then the link looks like:

The crucial thing in this example is using of the item id property “id=..”
Following code snippet shows how to create it:


private
static string createOwaIdForExch2007(ItemType exchMail)
{

            string owaUri;

            byte[] itemBinId = System.Convert.FromBase64String(exchMail.ItemId.Id);

            byte[] owaBinUri = new byte[72];

            owaBinUri[0] = 70;

            Array.Copy(itemBinId, 27, owaBinUri, 1, 70);

            owaBinUri[owaBinUri.Length - 1] = 9 //(means message type);

            owaUri = Convert.ToBase64String(owaBinUri);

            owaUri = System.Web.HttpUtility.UrlEncode(owaUri);

            return owaUri;

}

private static string createOwaIdForExch2010(ItemType exchMail)
{

            string owaUri;

            byte[] itemBinId = System.Convert.FromBase64String(exchMail.ItemId.Id);

            byte[] owaBinUri = new byte[72];

            owaBinUri[0] = 70;

            Array.Copy(itemBinId, 23, owaBinUri, 1, 70);

            owaBinUri[owaBinUri.Length - 1] = 9 //(means message type);

            owaUri = Convert.ToBase64String(owaBinUri);

            owaUri = System.Web.HttpUtility.UrlEncode(owaUri);

            return owaUri;

}

 
This example can be useful if you want to create OWA-uri of some other types.
Hope this helps you. If you want to help me please don't’ ask me how I have found the number 70 and 27 (23) :)



Posted Apr 15 2010, 04:46 PM by Damir Dobric
developers.de is a .Net Community Blog powered by daenet GmbH.