0

I am making use of this piece of code to set the color. It;s setting color on my computer, but when I send appointments to others, the color is not getting set in their calendar after they accept it.

ExtendedPropertyDefinition propDefColor = new ExtendedPropertyDefinition(
  UUID.fromString("00062002-0000-0000-c000-000000000046"),
  0x8214, MapiPropertyType.Integer);
appointment.setExtendedProperty(propDefColor, "6");

I tried to retrieve it after saving an appointment with this piece of code, but it didn't work.

PropertySet propset=new PropertySet(BasePropertySet.FirstClassProperties, propDefColor);
appointment.bind(service,appointment.getId(), propset);
for(ExtendedProperty extendedProperty : appointment.getExtendedProperties()) {
  System.out.println(extendedProperty.getValue());
}

And I am using:

ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2007_SP1);

For client requirement. And Java EWS API1.2.

Kindly let me know how to get the color in other clients. (I don't know how to use MasterCategorylist or categories or tryGetProperty()).

Kindly help me in this. If we need to use tryGetProperty(), then how to pass the parameters in it?

  1. Propertydefinitionenter code here
  2. OutParam<Object>

Kindly help.

JasonMArcher
  • 14,195
  • 22
  • 56
  • 52

2 Answers2

3

Not answering you 'all the way' but maybe this helps you further.
I hard code EWS XML requests and this is how I retrieve the master configuration list:

<soap:Envelope xmlns:mes="http://schemas.microsoft.com/exchange/services/2006/messages"
               xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types"
               xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
  <soap:Header>
    <typ:RequestServerVersion Version="Exchange2010" />
  </soap:Header>
  <soap:Body>
    <mes:GetUserConfiguration>
      <mes:UserConfigurationName Name="CategoryList">
        <typ:DistinguishedFolderId Id="calendar"/>
      </mes:UserConfigurationName>
      <mes:UserConfigurationProperties>All</mes:UserConfigurationProperties>
    </mes:GetUserConfiguration>
  </soap:Body>
</soap:Envelope>

The answer is:

<s:Envelope xmlns:s="http://schemas.xmlsoap.org/soap/envelope/">
   <s:Header>
      <h:ServerVersionInfo MajorVersion="14" MinorVersion="0" MajorBuildNumber="722" MinorBuildNumber="0" Version="Exchange2010" xmlns:h="http://schemas.microsoft.com/exchange/services/2006/types" xmlns="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"/>
   </s:Header>
   <s:Body xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
      <m:GetUserConfigurationResponse xmlns:m="http://schemas.microsoft.com/exchange/services/2006/messages" xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
         <m:ResponseMessages>
            <m:GetUserConfigurationResponseMessage ResponseClass="Success">
               <m:ResponseCode>NoError</m:ResponseCode>
               <m:UserConfiguration>
                  <t:UserConfigurationName Name="CategoryList">
                     <typ:DistinguishedFolderId Id="calendar" xmlns:typ="http://schemas.microsoft.com/exchange/services/2006/types"/>
                  </t:UserConfigurationName>
                  <t:ItemId Id="AAMkADkyZ[snip]fSM9AAA=" ChangeKey="CQAAAB[snip]p3Law"/>
                  <t:XmlData>77u/PD94bW[snip]lcz4NCg==</t:XmlData>
               </m:UserConfiguration>
            </m:GetUserConfigurationResponseMessage>
         </m:ResponseMessages>
      </m:GetUserConfigurationResponse>
   </s:Body>
</s:Envelope>

That xmldata is what you want. It's Base64 encoded, if you decode it, it reads:

<?xml version="1.0"?>
  <categories default="Red Category" lastSavedSession="2" lastSavedTime="2013-07-29T07:47:43.0411241Z" xmlns="CategoryList.xsd">
  <category name="Red Category" color="0" keyboardShortcut="0" usageCount="2" lastTimeUsedNotes="1601-01-01T00:00:00Z" lastTimeUsedJournal="1601-01-01T00:00:00Z" lastTimeUsedContacts="1601-01-01T00:00:00Z" lastTimeUsedTasks="1601-01-01T00:00:00Z" lastTimeUsedCalendar="1601-01-01T00:00:00Z" lastTimeUsedMail="1601-01-01T00:00:00Z" lastTimeUsed="2010-09-29T10:08:46.487Z" lastSessionUsed="0" guid="{61c23d24-ed86-47ec-8565-433e3a6b21b7}" renameOnFirstUse="1" />
  <category name="Blue Category" color="7" keyboardShortcut="0" usageCount="6" lastTimeUsedNotes="1601-01-01T00:00:00Z" lastTimeUsedJournal="1601-01-01T00:00:00Z" lastTimeUsedContacts="1601-01-01T00:00:00Z" lastTimeUsedTasks="1601-01-01T00:00:00Z" lastTimeUsedCalendar="2013-04-17T09:10:04.043Z" lastTimeUsedMail="1601-01-01T00:00:00Z" lastTimeUsed="2013-04-17T09:10:04.043Z" lastSessionUsed="2" guid="{e19dd512-bff1-46d8-a858-54cc114872ad}" renameOnFirstUse="0" />
  <category name="Purple Category" color="8" keyboardShortcut="0" usageCount="2" lastTimeUsedNotes="1601-01-01T00:00:00Z" lastTimeUsedJournal="1601-01-01T00:00:00Z" lastTimeUsedContacts="1601-01-01T00:00:00Z" lastTimeUsedTasks="1601-01-01T00:00:00Z" lastTimeUsedCalendar="1601-01-01T00:00:00Z" lastTimeUsedMail="1601-01-01T00:00:00Z" lastTimeUsed="2010-09-29T10:08:46.487Z" lastSessionUsed="0" guid="{fd3afb30-285e-4bf2-885e-f9fdfe00002e}" renameOnFirstUse="1" />
  <category name="Green Category" color="4" keyboardShortcut="0" usageCount="6" lastTimeUsedNotes="1601-01-01T00:00:00Z" lastTimeUsedJournal="1601-01-01T00:00:00Z" lastTimeUsedContacts="1601-01-01T00:00:00Z" lastTimeUsedTasks="1601-01-01T00:00:00Z" lastTimeUsedCalendar="2013-04-17T09:10:12.782Z" lastTimeUsedMail="1601-01-01T00:00:00Z" lastTimeUsed="2013-04-17T09:10:12.782Z" lastSessionUsed="2" guid="{c3dc51d0-1cc4-42cf-9fa9-75146905771f}" renameOnFirstUse="0" />
  <category name="Orange Category" color="1" keyboardShortcut="0" usageCount="2" lastTimeUsedNotes="1601-01-01T00:00:00Z" lastTimeUsedJournal="1601-01-01T00:00:00Z" lastTimeUsedContacts="1601-01-01T00:00:00Z" lastTimeUsedTasks="1601-01-01T00:00:00Z" lastTimeUsedCalendar="1601-01-01T00:00:00Z" lastTimeUsedMail="1601-01-01T00:00:00Z" lastTimeUsed="2010-09-29T10:08:46.487Z" lastSessionUsed="0" guid="{10c78b6f-5828-4b3c-af0c-138aaac52dae}" renameOnFirstUse="1" />
  <category name="Yellow Category" color="3" keyboardShortcut="0" usageCount="2" lastTimeUsedNotes="1601-01-01T00:00:00Z" lastTimeUsedJournal="1601-01-01T00:00:00Z" lastTimeUsedContacts="1601-01-01T00:00:00Z" lastTimeUsedTasks="1601-01-01T00:00:00Z" lastTimeUsedCalendar="1601-01-01T00:00:00Z" lastTimeUsedMail="1601-01-01T00:00:00Z" lastTimeUsed="2010-09-29T10:08:46.487Z" lastSessionUsed="0" guid="{37cc21d3-b6a9-4dae-a1fb-422249b9fbb0}" renameOnFirstUse="1" />
  <category name="TimeTell" color="7" keyboardShortcut="0" usageCount="7" lastTimeUsedNotes="1601-01-01T00:00:00Z" lastTimeUsedJournal="1601-01-01T00:00:00Z" lastTimeUsedContacts="1601-01-01T00:00:00Z" lastTimeUsedTasks="1601-01-01T00:00:00Z" lastTimeUsedCalendar="2013-07-29T07:31:17.8034765Z" lastTimeUsedMail="1601-01-01T00:00:00Z" lastTimeUsed="2013-07-29T07:31:17.8034765Z" lastSessionUsed="2" guid="{3348e50b-1763-42fb-a9e9-25b74038b9aa}" renameOnFirstUse="0" />
</categories>

And there you have the categories and associated colors.

Jan Doggen
  • 8,799
  • 13
  • 70
  • 144
0

I redid the code using another lib that made it easier. It takes care of getting/setting all the fields.

Mark
  • 1
  • 2
    Note that [link-only answers are discouraged](http://meta.stackoverflow.com/tags/link-only-answers/info), SO answers should be the end-point of a search for a solution (vs. yet another stopover of references, which tend to get stale over time). Please consider adding a stand-alone synopsis here, keeping the link as a reference. – kleopatra Oct 20 '13 at 10:21