none
[E2013] [EWS] [PHP] [Windows] : Creating navigation shortcut pointing to a calendar, getting draft message instead. RRS feed

  • Question

  • Hi,

    A couple days ago we asked about how to create a shared calendar without the need to accept a sharing request email. We got this answer: http://social.msdn.microsoft.com/Forums/exchange/en-US/eb49d42d-f961-42f6-8732-4bc3d0987b18/sharing-a-calendar-using-ews-and-phpews-without-sending-share-invitation

    We read the documentation and started trying the implementation to make it work. So far this is the properties we set for our request to the method CreateItem

    //PidTagMessageClass 
    $sType = new EWSType_PathToExtendedFieldType();
    $sType->PropertyTag = "0x001A";
    $sType->PropertyType = EWSType_MapiPropertyTypeType::STRING;
    
    $objExtendedPropertyType = new EWSType_ExtendedPropertyType();
    $objExtendedPropertyType->ExtendedFieldURI = $sType;
    $objExtendedPropertyType->Value = "IPM.Microsoft.WunderBar.Link";
    $a_sExtendedProperties[] = $objExtendedPropertyType;
    
    //PidTagNormalizedSubject  
    $sType = new EWSType_PathToExtendedFieldType();
    $sType->PropertyTag = "0x0E1D";
    $sType->PropertyType = EWSType_MapiPropertyTypeType::STRING;
    
    $objExtendedPropertyType = new EWSType_ExtendedPropertyType();
    $objExtendedPropertyType->ExtendedFieldURI = $sType;
    $objExtendedPropertyType->Value = "Meetings";
    $a_sExtendedProperties[] = $objExtendedPropertyType;
    
    //PidTagWlinkSaveStamp   
    //$sType = new EWSType_PathToExtendedFieldType();
    //$sType->PropertyTag = "0x0E1D";
    //$sType->PropertyType = EWSType_MapiPropertyTypeType::STRING;
    //
    //$objExtendedPropertyType = new EWSType_ExtendedPropertyType();
    //$objExtendedPropertyType->ExtendedFieldURI = $sType;
    //$objExtendedPropertyType->Value = "Meetings";
    //$a_sExtendedProperties[] = $objExtendedPropertyType;
    
    //PidTagWlinkType
    $sType = new EWSType_PathToExtendedFieldType();
    $sType->PropertyTag = "0x6849";
    $sType->PropertyType = EWSType_MapiPropertyTypeType::INTEGER;
    
    $objExtendedPropertyType = new EWSType_ExtendedPropertyType();
    $objExtendedPropertyType->ExtendedFieldURI = $sType;
    $objExtendedPropertyType->Value = 2;
    $a_sExtendedProperties[] = $objExtendedPropertyType;
    
    //PidTagWlinkFlags
    $sType = new EWSType_PathToExtendedFieldType();
    $sType->PropertyTag = "0x684A";
    $sType->PropertyType = EWSType_MapiPropertyTypeType::INTEGER;
    
    $objExtendedPropertyType = new EWSType_ExtendedPropertyType();
    $objExtendedPropertyType->ExtendedFieldURI = $sType;
    $objExtendedPropertyType->Value = 1024;
    $a_sExtendedProperties[] = $objExtendedPropertyType;
    
    //PidTagWlinkOrdinal 
    //$sType = new EWSType_PathToExtendedFieldType();
    //$sType->PropertyTag = "0x684B";
    //$sType->PropertyType = EWSType_MapiPropertyTypeType::BINARY;
    //
    //$objExtendedPropertyType = new EWSType_ExtendedPropertyType();
    //$objExtendedPropertyType->ExtendedFieldURI = $sType;
    //$objExtendedPropertyType->Value = 1024;
    //$a_sExtendedProperties[] = $objExtendedPropertyType;
    
    //PidTagWlinkEntryId 
    $sType = new EWSType_PathToExtendedFieldType();
    //$sType->PropertyTag = "0x0FFF";
    $sType->PropertyTag = "0x684C";
    $sType->PropertyType = EWSType_MapiPropertyTypeType::BINARY;
    
    $objExtendedPropertyType = new EWSType_ExtendedPropertyType();
    $objExtendedPropertyType->ExtendedFieldURI = $sType;
    $objExtendedPropertyType->Value = $sEntryID;
    $a_sExtendedProperties[] = $objExtendedPropertyType;
    
    //PidTagWlinkRecordKey  
    $sType = new EWSType_PathToExtendedFieldType();
    //$sType->PropertyTag = "0x0FF9";
    $sType->PropertyTag = "0x684D";
    $sType->PropertyType = EWSType_MapiPropertyTypeType::BINARY;
    
    $objExtendedPropertyType = new EWSType_ExtendedPropertyType();
    $objExtendedPropertyType->ExtendedFieldURI = $sType;
    $objExtendedPropertyType->Value = $sRecordID;
    $a_sExtendedProperties[] = $objExtendedPropertyType;
    
    //PidTagWlinkStoreEntryId  
    $sType = new EWSType_PathToExtendedFieldType();
    //$sType->PropertyTag = "0x0FFB";
    $sType->PropertyTag = "0x684E";
    $sType->PropertyType = EWSType_MapiPropertyTypeType::BINARY;
    
    $objExtendedPropertyType = new EWSType_ExtendedPropertyType();
    $objExtendedPropertyType->ExtendedFieldURI = $sType;
    $objExtendedPropertyType->Value = $sStoreID;
    $a_sExtendedProperties[] = $objExtendedPropertyType;
    
    //PidTagWlinkFolderType
    $sType = new EWSType_PathToExtendedFieldType();
    $sType->PropertyTag = "0x684F";
    $sType->PropertyType = EWSType_MapiPropertyTypeType::CLSID;
    
    $objExtendedPropertyType = new EWSType_ExtendedPropertyType();
    $objExtendedPropertyType->ExtendedFieldURI = $sType;
    //$objExtendedPropertyType->Value = '{0x02780600, 0x0000, 0x0000, {0xC0, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x46}}';
    $objExtendedPropertyType->Value = '0006F063-0000-0000-C000-000000000046';
    $a_sExtendedProperties[] = $objExtendedPropertyType;
    
    //PidTagWlinkSection
    $sType = new EWSType_PathToExtendedFieldType();
    $sType->PropertyTag = "0x6852";
    $sType->PropertyType = EWSType_MapiPropertyTypeType::INTEGER;
    
    $objExtendedPropertyType = new EWSType_ExtendedPropertyType();
    $objExtendedPropertyType->ExtendedFieldURI = $sType;
    $objExtendedPropertyType->Value = '3';
    $a_sExtendedProperties[] = $objExtendedPropertyType;
    
    $request = new EWSType_CreateItemType();
    $request->Items = new EWSType_CreateItemType();
    $request->Items->Item = new EWSType_ItemType();
    //$request->Items->Item->ItemClass = "IPM.Microsoft.WunderBar.Link";
    //$request->Items->Item->Subject = "SharedCalendar";
    $request->Items->Item->ExtendedProperty = $a_sExtendedProperties;
    
    $request->ParentFolderId = new EWSType_NonEmptyArrayOfBaseFolderIdsType();
    $request->ParentFolderId->DistinguishedFolderId = new EWSType_DistinguishedFolderIdType();
    $request->ParentFolderId->DistinguishedFolderId->Id = EWSType_DistinguishedFolderIdNameType::CALENDAR;
    $request->ParentFolderId->DistinguishedFolderId->Mailbox = new EWSType_MailboxData();
    $request->ParentFolderId->DistinguishedFolderId->Mailbox->EmailAddress = 'user@domain.ca';
    $request->ParentFolderId->DistinguishedFolderId->Mailbox->RoutingType  = 'SMTP';
    
    
    $response = $ews->CreateItem($request);

    We use FindItem with extended properties to fill the value
    $sEntryID = 0x0FFF
    $sStoreID = 0x0FFB
    $sRecordID = 0x0FF9

    When we run this script, we are getting a draft message instead of a navigation shortcut.

    We tried writing the $sEntryID, $sStoreID, $sRecordID at the same property tag as the one we got them from but we get an error 503 from the server.

    We think we are near the final answer but there is a gap we can't make it work. If anyone has an answer to fill that gap we will greatly appreciate it.

    Thanks and have a nice day.

    Wednesday, June 19, 2013 2:45 PM

All replies

  • The Navigational Shortcuts are FAI (Folder Assoicated Items) and they need to be saved to the CommonViews Folder http://msdn.microsoft.com/en-us/library/office/cc815648.aspx of the Mailbox in question. (You should really use a MAPI Editor to look at a Mailbox yourself or you just wont understand this http://technet.microsoft.com/en-us/library/bb508857(v=exchg.65).aspx).

    You also need to use the MessageType else you wont be able to modify the ItemClass and you need to set the IsAssocated Properties so the Item is saved as an FAI Item (which you will only able to view with a Mapi editor).

                MessageType msType = new MessageType();
                msType.IsAssociated = true;
                msType.IsAssociatedSpecified = true;
    Cheers
    Glen

    Thursday, June 20, 2013 10:18 AM
  • Hi,

    Thanks again Glen for your help, I downloaded MFCMAPI, OutlookSpy and EWSEditor.

    With OutlookSpy, I can't get the properties of the elements of my shared calendar. So I went with MFCMAPI instead and finally got to see the properties of the objects in my mailbox.

    There is only a small problem, maybe I lack knowledge about how Exchange keeps the data, but there is nothing in my folder Common Views, the shared calendar I have in my mailbox are in Shared Data.

    When I open my shared calendar in MFCMAPI, I don't have the properties (IsAssociated, IsAssociatedSpecified) in the object.

    I also tried to make a MessageType instead of ItemType, but I still get a draft message. When I check the values they seems correct but there are some attributes missing I presume it's for the same reason we get a draft message instead.

    Thursday, June 20, 2013 7:31 PM
  • > but there is nothing in my folder Common Views, the shared calendar I have in my mailbox are in Shared Data.

    You need to use the Open Associated Content to see the FAI items in the folder, MFCMapi let you look at the MAPI properties of a object, the Strongly type properties of the Web Service Object are different (generally their is an underlying MAPI property to match it).

    >I also tried to make a MessageType instead of ItemType, but I still get a draft message. >When I check the values they seems correct but there are some attributes missing I >presume it's for the same reason we get a draft message instead.

    You need to use the IsAssoicated properties to make sure the message is saved to FAI collection (or the commonview folder which you will need to find the Id of using FindFolder operations) once it is you won't be able to see the Items in the folder without a Mapi editor. Being a draft is just a misnomer is not important one way of the other. But you need to look at an existing ShortCut Item to help make what your trying to do work.

    Cheers
    Glen

    Friday, June 21, 2013 12:02 PM
  • Hi Mr Scales

    We finally found the FAI with your help. Thank you very much.

    While comparing the values, we noticed the property PR_MESSAGE_FLAGS has a value of 73 while the ones we are creating have a value of 9. So we assume the IsAssociated property we set is saved in that property. The problem we have now is when we try to edit the value using MFCMAPI, we get an error:

    Problem array:
    Index: 0x00000000, ulPropTag: Tag: 0x0E070003
    Type: PT_LONG
    Property Name(s): PR_MESSAGE_FLAGS, PidTagMessageFlags, ptagMessageFlags
    DASL: http://schemas.microsoft.com/mapi/proptag/0x0E070003, scode: 0x8004011A = MAPI_E_COMPUTED

    In file PropertyEditor.cpp
    On line 720

    Another problem we encounter is when we set the IsAssociated on a message type, we get this error:

    The request failed schema validation: The element 'Message' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types' has invalid child element 'IsAssociated' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'. List of possible elements expected: 'WebClientReadFormQueryString, WebClientEditFormQueryString, ConversationId, UniqueBody, Sender, ToRecipients, CcRecipients, BccRecipients, IsReadReceiptRequested, IsDeliveryReceiptRequested, ConversationIndex, ConversationTopic, From, InternetMessageId, IsRead, IsResponseRequested, References, ReplyTo, ReceivedBy, ReceivedRepresenting' in namespace 'http://schemas.microsoft.com/exchange/services/2006/types'.

    Here is the request we send to the server

    <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:ns1="http://schemas.microsoft.com/exchange/services/2006/types" xmlns:ns2="http://schemas.microsoft.com/exchange/services/2006/messages">
    	<SOAP-ENV:Header>
    		<ns1:RequestServerVersion Version="Exchange2010"/>
    		<ns1:ExchangeImpersonation>
    			<ns1:ConnectingSID>
    				<ns1:PrimarySmtpAddress>name@domain.com</ns1:PrimarySmtpAddress>
    			</ns1:ConnectingSID>
    		</ns1:ExchangeImpersonation>
    	</SOAP-ENV:Header>
    	<SOAP-ENV:Body>
    		<ns2:CreateItem MessageDisposition="SaveOnly">
    			<ns2:SavedItemFolderId>
    				<ns1:FolderId Id="AQMkADhkMjIAOGJlMi1hZTU4LTQwNzcALTliNTEtMjFjMjVmYTI5YzZmAC4AAAMUYhf/m7/tS4JqTUCpQ3mcAQDgBdgbPZMxQ5EP5jMlLTMUAAADBwAAAA==" ChangeKey="AQAAABYAAADgBdgbPZMxQ5EP5jMlLTMUAAAAAAAv"/>
    			</ns2:SavedItemFolderId>
    			<ns2:Items>
    				<ns1:Message>
    					<ns1:ItemClass>IPM.Microsoft.WunderBar.Link</ns1:ItemClass>
    					<ns1:ExtendedProperty>
    						<ns1:ExtendedFieldURI PropertyTag="0x0E1D" PropertyType="String"/>
    						<ns1:Value>Meetings</ns1:Value>
    					</ns1:ExtendedProperty>
    					<ns1:ExtendedProperty>
    						<ns1:ExtendedFieldURI PropertyTag="0x6849" PropertyType="Integer"/>
    						<ns1:Value>2</ns1:Value>
    					</ns1:ExtendedProperty>
    					<ns1:ExtendedProperty>
    						<ns1:ExtendedFieldURI PropertyTag="0x684A" PropertyType="Integer"/>
    						<ns1:Value>0</ns1:Value>
    					</ns1:ExtendedProperty>
    					<ns1:ExtendedProperty>
    						<ns1:ExtendedFieldURI PropertyTag="0x684C" PropertyType="Binary"/>
    						<ns1:Value>AAAAABuFufJwK7JLrrjtyLW4G74BAJILSV5u+zNNgnSrc3p/IHUAAAsLERYAAA==</ns1:Value>
    					</ns1:ExtendedProperty>
    					<ns1:ExtendedProperty>
    						<ns1:ExtendedFieldURI PropertyTag="0x684D" PropertyType="Binary"/>
    						<ns1:Value>G4W58nArskuuuO3Itbgbvg==</ns1:Value>
    					</ns1:ExtendedProperty>
    					<ns1:ExtendedProperty>
    						<ns1:ExtendedFieldURI PropertyTag="0x684E" PropertyType="Binary"/>
    						<ns1:Value>AAAAADihuxAF5RAaobsIACsqVsIAAEVNU01EQi5ETEwAAAAAAAAAABtV+iCqZhHNm8gAqgAvxFoMAAAAU2VydmVyMDIuYWQuZXptYXguY2EA+IiE9XzbjEiqZSWmrHNVveTfb5k2QxhGt33Pu/mxDMM=</ns1:Value>
    					</ns1:ExtendedProperty>
    					<ns1:ExtendedProperty>
    						<ns1:ExtendedFieldURI PropertyTag="0x6852" PropertyType="Integer"/>
    						<ns1:Value>3</ns1:Value>
    					</ns1:ExtendedProperty>
    					<ns1:ExtendedProperty>
    						<ns1:ExtendedFieldURI PropertyTag="0x0E07" PropertyType="Integer"/>
    						<ns1:Value>73</ns1:Value>
    					</ns1:ExtendedProperty>
    					<ns1:IsAssociated>true</ns1:IsAssociated>
    				</ns1:Message>
    			</ns2:Items>
    		</ns2:CreateItem>
    	</SOAP-ENV:Body>
    </SOAP-ENV:Envelope>

    We think we are getting closer each day to the solution and we appreciate your help.

    Thank you very much and have a nice day.

    Thursday, July 4, 2013 6:06 PM
  • The ability to create FAI (Folder Assoicated Items) was added in Exchange 2010 (see http://msdn.microsoft.com/en-us/library/exchange/aa494306%28v=exchg.140%29.aspx) it sounds like the proxies your using where generated against an Exchange 2007 server or maybe your server hasn't been patched (check the definition). I would try to regenerate the proxy. The only way to create an FAI Item using EWS it to use this property.

    The MessageFlags property is Computed from other property values so you can't modify it once its been created.

    Cheers
    Glen

    Friday, July 5, 2013 11:25 PM
  • Hi once again!

    Thanks to your help, we finally see the FAI in the Common views, the only problem we still have is we don't see it in the user's Outlook.

    We have set every value explained here http://msdn.microsoft.com/en-us/library/ee157359%28v=exchg.80%29.aspx.

    When we compare to a shortcut we made using the sharing email method, we have different properties that are not mentionned in the documentation, like PR_WLINK_AB_EXSTOREEID and PR_WLINK_ABEID.

    Those value seems to be a long binary string containing the informations to the user sharing the calendar mailbox. I found documentation on internet on how to build this string but I need to have the x500 and userdn of the sharing user but I didn't find any request in the EWS documentation. So I was wondering if it was values we could obtain automatically or we had to find them manually.

    Thanks once again for your help, it is really appreciated, this problem is really troubling us.

    Have a nice day

    Wednesday, July 17, 2013 5:18 PM
  • You can get the X500 address of the user from AutoDiscover. Eg you need to make a Autodiscover request for the user you want to obtain it for http://msdn.microsoft.com/en-us/library/exchange/bb204082(v=exchg.140).aspx and get the value from the LegacyDN node in the response.

    Cheers
    Glen

    Thursday, July 18, 2013 4:58 AM
  • Hi again,

    The autodiscory request worked and I got my X500 address.

    But I still can't get it to show the link in the user's outlook. I've compared a shared link from a normal sharing request email with the one I created and all the values seems to be there. There is some problems I can't find answers for:

    1. I have some extra properties in the object I created with my script.

    2. When I try to copy the value from the working one to the one I created, Exchange destroys it.

    3. If it's not showing, is it a problem with the linking? Is there a way to validate the value we have in the PR_WLINK to see if they are correct? I've read the documentation you sent at the very beginning and I think I have set all the necessary properties required with the correct values. Is there other properties that are important but are not mentionned?

    Sorry to be a bother, but you are the only person with the knowledge to help us.

    Have a  nice day

    Friday, July 19, 2013 1:29 PM
  • 1. And your question is ?

    2 What value ? what property ? some properties shouldn't be copied as they maybe computed or an identifier.

    3. If you create a Shortcut manually in Outlook then the values should match.

    >> Is there other properties that are important but are not mentionned?

    I don't know of working sample for this so possibly you can try the documentation forum http://social.msdn.microsoft.com/Forums/en-US/home?forum=os_exchangeprotocols .

    The one thing to be careful of when your testing these is that Outlook and OWA do cache these Items so you need to make sure you restart the client to ensure any changes take affect.

    Cheers
    Glen

    Monday, July 22, 2013 6:31 AM