Interacting with the Exchange Web Services

2,285 views

Published on

Tips on using Exchange Web Services to create Contacts, Distribution Lists, extended properties, ...

Published in: Technology, Business
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
2,285
On SlideShare
0
From Embeds
0
Number of Embeds
10
Actions
Shares
0
Downloads
26
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Interacting with the Exchange Web Services

  1. 1. 9 October, 2008<br />Interacting with the Exchange Web Services, by Wim De Coninck<br />
  2. 2. Exchange Web Services Architecture<br />9 October, 2008<br />Interacting with the Exchange Web Services,by Wim De Coninck<br />2<br />
  3. 3. Exchange Web Service: Whatcan we do withit?<br />Interacting with the Exchange Web Services,by Wim De Coninck<br />9 October, 2008<br /><ul><li>Autodiscover
  4. 4. Calendaring
  5. 5. Contact
  6. 6. Folder
  7. 7. Server Management
  8. 8. Messaging
  9. 9. MIME
  10. 10. Security
  11. 11. Store EventSinks
  12. 12. Store Schemas
  13. 13. Store
  14. 14. Synchronization
  15. 15. Task Item
  16. 16. Utility
  17. 17. Notification
  18. 18. Web services</li></ul>3<br />
  19. 19. Creating a basic contact<br />4<br />Interacting with the Exchange Web Services,by Wim De Coninck<br />9 October, 2008<br /><ul><li>Instantiate a ContactItemType
  20. 20. Set somepropertieson the contact
  21. 21. Specify the folder whereyou want the contact
  22. 22. Instantiate a CreateItemType
  23. 23. Add the contact to the createItem
  24. 24. Invoke the CreateItemmethodon the webservice.
  25. 25. Process the response of the CreateItemmethod.</li></li></ul><li>Zooming in...<br />To set email addresson a contact, create a new List of EmailAddressDictionaryEntryType and add the email address to the array, thenadd the array to the contact’s email addressesproperty…<br />var contact = newContactItemType();<br />varemails = newList&lt;EmailAddressDictionaryEntryType&gt;<br />                {<br />                    newEmailAddressDictionaryEntryType<br />                        {<br />                            Key = EmailAddressKeyType.EmailAddress1,<br />                            Value = &quot;mail1@example.com&quot;<br />                        },<br />                    newEmailAddressDictionaryEntryType<br />                        {<br />                            Key = EmailAddressKeyType.EmailAddress1,<br />                            Value = &quot;mail2@example.com&quot;<br />                        }<br />                };<br />contact.EmailAddresses = emails.ToArray();<br />Imaginedoingthis pre Framework 3.5<br />9 October, 2008<br />Interacting with the Exchange Web Services,by Wim De Coninck<br />5<br />
  26. 26. Anextendedproperty is a propertythatcanbe set onan item butwhich is notpresentedthrough the webservice out of the box. For instance the gender of a contact.<br />In this case we wouldcreate a newExtendedproperty. The ExtendedFieldURI of thatproperty is a path to extended field type whichmaps to a propertythat is visible in outlook. The item willcontain the valuethat is to bedisplayed in the specified field.<br />ExtendedPropertyTypegender = <br />newExtendedPropertyType();<br />gender.ExtendedFieldURI = <br />newPathToExtendedFieldType();<br />gender.ExtendedFieldURI.PropertyTag = &quot;0x3a4d&quot;;<br />gender.ExtendedFieldURI.PropertyType = MapiPropertyTypeType.Short;<br />gender.Item = ((int)pGender).ToString();<br />ExtendedProperties<br />Interacting with the Exchange Web Services,by Wim De Coninck<br />9 October, 2008<br />6<br />
  27. 27. 7<br />Interacting with the Exchange Web Services,by Wim De Coninck<br />9 October, 2008<br />
  28. 28. Distribution List<br />Youcan’tcreate a distribution list. The CreateItem web method does notallowyou to add a DistributionList.<br />How do we workaroundthat ?<br />Createan itemtype and addextendedproperties ‘tillitbecomes a distributionlist, and set the ItemClass to IPM.DistList<br />9 October, 2008<br />Interacting with the Exchange Web Services,by Wim De Coninck<br />8<br />
  29. 29. Adding the members<br />WARNING:<br />2 Extendedproperties:<br />Member<br />OneOffMember<br />Both expect a BinaryArray. <br />They are limited to 15000 bytes, (about 140 contact entries)<br />Foreach entry in memberthere must bean entry in oneOffMember at the same index.<br />BinaryArrayequals Base64String[]<br />9 October, 2008<br />Interacting with the Exchange Web Services,by Wim De Coninck<br />9<br />
  30. 30. Member<br />A membercontains a link to contact through a hexed entry id. <br />What we have is the ItemId and the ConvertId web method.<br />ConvertIdTypeconvertReq = newConvertIdType();<br />convertReq.DestinationFormat = IdFormatType.HexEntryId;<br />convertReq.SourceIds = new[]<br />       {<br />           newAlternateIdType()<br />               {<br />                   Format = IdFormatType.EntryId,<br />                   Mailbox = &quot;administrator@litwareinc.com&quot;,<br />                   Id = item.ItemId.Id<br />               }<br />       };<br />ConvertIdResponseType response = esb.ConvertId(convertReq);<br />9 October, 2008<br />Interacting with the Exchange Web Services,by Wim De Coninck<br />10<br />
  31. 31. Member: the actual base 64 string<br />The wrapped entry id is what we want in the base 64 string.<br />Prefix of wrapped entry id = <br />00000000C091ADD3519DCF11A4A900AA0047FAA4C300000000<br />The response contains a stringwith bytes.<br />We onlyneed part a of the retreivedstring.<br />0003240033636237313064392D323134342D343761632D626137612D393730646364656335343664004600000000002F6E0D571298F14DA8E47B5FEDAA78A507001DD4ACE8303DD54F87DD53DA592670810001F3D7468A00000988B48B0E4D054284347C283576FD020424930B44BC0000<br />9 October, 2008<br />Interacting with the Exchange Web Services,by Wim De Coninck<br />11<br />
  32. 32. OneOffMember<br />12<br />Interacting with the Exchange Web Services,by Wim De Coninck<br />9 October, 2008<br />varretval = newList&lt;byte&gt;();<br /> <br />varflags = Encoding.Unicode.GetBytes(&quot;&quot;);<br />varversion = Encoding.Unicode.GetBytes(&quot;&quot;);<br />var pad = Encoding.Unicode.GetBytes(&quot;&quot;);<br />varmuid = newbyte[]<br />                  {<br />                      0x81, 0x2b, 0x1f, 0xa4, 0xbe, <br />                      0xa3, 0x10, 0x19, 0x9d, 0x6e, <br />                      0x00, 0xdd, 0x01, 0x0f, 0x54, 0x02<br />                  };<br />varwFlags = newbyte[] { 0x01, 0x90 };<br />varfirst = Encoding.Unicode.GetBytes(“contactname(email@d.com)”);<br />varmiddle = Encoding.Unicode.GetBytes(&quot;UNKNOWN&quot;);<br />var last = Encoding.Unicode.GetBytes(“email@d.com”);<br /> <br />retval.AddRange(flags);<br />retval.AddRange(muid);<br />retval.AddRange(version);<br />retval.AddRange(wFlags);<br />retval.AddRange(first);<br />retval.AddRange(pad);<br />retval.AddRange(middle);<br />retval.AddRange(pad);<br />retval.AddRange(last);<br />retval.AddRange(pad);<br />
  33. 33. Resources<br />http://msdn.microsoft.com/en-us/library/bb408417.aspx<br />9 October, 2008<br />Interacting with the Exchange Web Services,by Wim De Coninck<br />13<br />
  34. 34. 14<br />Interacting with the Exchange Web Services,by Wim De Coninck<br />9 October, 2008<br />

×