Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 494
  • Last Modified:

Opening new contact record using URL

I am using WEBDAV to create a new contact record in Exchange. The XML is created using the PHP code below and it does create the new contact record successfully.

I then pass to a web interface where I am using a URL to force Outlook to open the newly created account. in the form:-

outlook://Public%20Folders/All%20Public%20Folders/Company%20Contacts/~givenName%20surname

However when I click on the link Outlook fails to open the record with an error message:-

"! Cannot display the selected folder or item."

If however I open the record in Outlook and make a trivial edit such as adding a single letter to the notes field and save it: the URL then works with no problem. This suggests some sort of index issue. However if it is, it isn't a cyclical update as  leaving the records a few days makes no difference only editing the record.

Can anyone suggest whether I'm missing something or need to do something different?

$strXMLInsertText = '<?xml version="1.0"?>';
$strXMLInsertText .= '<g:propertyupdate';
 $strXMLInsertText .= 'xmlns:g="DAV:"';
 $strXMLInsertText .= 'xmlns:b="urn:uuid:c2f41010-65b3-11d1-a29f-00aa00c14882/"';
 $strXMLInsertText .= 'xmlns:c="urn:schemas:contacts:"';
 $strXMLInsertText .= 'xmlns:e="http://schemas.microsoft.com/exchange/"';
 $strXMLInsertText .= 'xmlns:mapi="http://schemas.microsoft.com/mapi/"';
 $strXMLInsertText .= 'xmlns:o="urn:schemas-microsoft-com:office:office"';
 $strXMLInsertText .= 'xmlns:cust="urn:schemas:customproperty"';
 $strXMLInsertText .= 'xmlns:ed="urn:schemas-microsoft-com:exch-data:"';
 $strXMLInsertText .= 'xmlns:repl="http://schemas.microsoft.com/repl/"';
 $strXMLInsertText .= 'xmlns:x="xml:"';
 $strXMLInsertText .= 'xmlns:cal="urn:schemas:calendar:"';
 $strXMLInsertText .= 'xmlns:mail="urn:schemas:httpmail:"';
 $strXMLInsertText .= 'xmlns:ec="urn:schemas-microsoft-com:exch-data:expected-content-class"';
 $strXMLInsertText .= 'xmlns:j="urn:content-classes:propertydef"';
 $strXMLInsertText .= 'xmlns:mailheader="urn:schemas:mailheader:">';
 $strXMLInsertText .= '<g:set>';
  $strXMLInsertText .= '<g:prop>';
   $strXMLInsertText .= '<g:contentclass>urn:content-classes:person</g:contentclass>';
   $strXMLInsertText .= '<e:outlookmessageclass>IPM.Contact</e:outlookmessageclass>';
   $strXMLInsertText .= '<c:fileas>' . $strfileas . '</c:fileas>';
   $strXMLInsertText .= '<c:account>' . $intLastID . '</c:account>';
   $strXMLInsertText .= '<c:givenName>' . $strgivenName . '</c:givenName>';
   $strXMLInsertText .= '<c:middlename>' . $strmiddlename . '</c:middlename>';
   $strXMLInsertText .= '<c:sn>' . $strsn . '</c:sn>';
   $strXMLInsertText .= '<c:cn>' . $strgivenName . ' ' . $strsn . '</c:cn>';
   $strXMLInsertText .= '<c:o>' . $stro . '</c:o>';
   $strXMLInsertText .= '<c:title>' . $strtitle . '</c:title>';
   $strXMLInsertText .= '<mapi:email1addrtype>SMTP</mapi:email1addrtype>';
   $strXMLInsertText .= '<mapi:email1emailaddress>' . $stremail1emailaddress . '</mapi:email1emailaddress>';
   $strXMLInsertText .= '<mapi:email1originaldisplayname>' . $stremail1emailaddress . '</mapi:email1originaldisplayname>';
   $strXMLInsertText .= '<c:telephoneNumber>' . $strtelephoneNumber . '</c:telephoneNumber>';
   $strXMLInsertText .= '<c:street>' . $strstreet . '</c:street>';
   $strXMLInsertText .= '<c:l>' . $strl . '</c:l>';
   $strXMLInsertText .= '<c:st>' . $strst . '</c:st>';
   $strXMLInsertText .= '<c:postalcode>' . $strpostalcode . '</c:postalcode>';
   $strXMLInsertText .= '<c:co>' . $strco . '</c:co>';
   $strXMLInsertText .= '<e:keywords-utf8>';
     $strXMLInsertText .= '<x:v>Customer</x:v>';
     $strXMLInsertText .= '<x:v>Services</x:v>';
   $strXMLInsertText .= '</e:keywords-utf8>';
   $strXMLInsertText .= '</g:prop>';
 $strXMLInsertText .= '</g:set>';
$strXMLInsertText .= '</g:propertyupdate>';

Open in new window

0
cescentman
Asked:
cescentman
  • 8
  • 8
1 Solution
 
LeeDerbyshireCommented:
Outlook can be very fussy if some other properties are missing.  First thing I would try would be to add

   $strXMLInsertText .= '<mapi:fileunder>' . $strfileas . '</mapi:fileunder>';
   $strXMLInsertText .= '<mapi:fileunderid>-1</mapi:fileunderid>';

after the line

   $strXMLInsertText .= '<c:fileas>' . $strfileas . '</c:fileas>';
0
 
LeeDerbyshireCommented:
Actually, your code doesn't show where you send the PROPPATCH to.  I assume it's exactly the same URL you're passing to the outlook:// provider?
0
 
cescentmanAuthor Commented:
Thanks for this. I'll try the additional entries tonight. In answer to the other question, yes the same URL.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LeeDerbyshireCommented:
It's worth checking (using something like Exchange Explorer) that the item gets created at the URL that you think it is.  Exchange will happily change the URL if the fileas and fileunder properties get changed, even immediately after you created it.
0
 
cescentmanAuthor Commented:
Not had much success getting exchange explorer working. The version I found for download is ages old what version do you use?
0
 
LeeDerbyshireCommented:
I think there's only one version.  It's quite old, but works with all versions of Exchange that support WebDAV.  You need to be aware that you have to make sure that FBA is turned off (it can't handle that), and if you have SSL required, you have to specifiy that in the mailbox URL you are trying to open.
0
 
cescentmanAuthor Commented:
Bet it was the FBA stuff that stuffed me last time I tried. I've had interminable trouble getting WEBDAV working and don't want to touch it again. Ho HUM.
0
 
LeeDerbyshireCommented:
You could try something like Outlook Spy - that will show you an item's URL.  There's a time limited demo available.  Very useful for othere things, too, if you are doing Exchange coding.
0
 
cescentmanAuthor Commented:
The XML you suggested inserting made no difference unfortunately. Loading OutlookSpy There seem to be two changes to the object when I save it. the full name is added to ConversationTopic and also to subject. Can this be it? it seems unlikely.
0
 
LeeDerbyshireCommented:
I've never had to deliberately populate those, although I'm not surprised that Outlook does it.  Before you make any changes, is the PR_URL_NAME (0x6707001E) property equal to the URL you sent the PROPPATCH to?

Actually, the URL does tend to depend on the subject value for all kinds of items, so it would be a good idea to set the subject if you definitely need to know what the URL is going to be as soon as the item is created.
0
 
cescentmanAuthor Commented:
this is a very steep learning curve for me so please forgive ant stupidity.

1 I can't find how to read the property PR_URL_NAME (0x6707001E), sorry.

2 I have set:-

$strXMLInsertText .= '<mapi:subject>' . $strgivenName . ' ' . $strsn . '</mapi:subject>';

and it still doesn't work.

Thanks for the effort you are putting into this.
0
 
LeeDerbyshireCommented:
Do you have Outlook Spy successfully installed?  If so, then before actually opening the contact in Outlook, select it in the list, and click the IMessage button that was added by Outlook Spy.  On the GetProps tab, you should see either PR_URL_NAME or 0x6707001E in the Property Tag column, depending on whether it decides to show the property ID or the actual property name.
0
 
cescentmanAuthor Commented:
Got that, and also reolved the issue. It seems that adding the subject line in the XML did in fact resolve the issue but the step in my code to open the Outlook record using:-

outlook://Public%20Folders/All%20Public%20Folders/Company%20Contacts/~givenName%20surname

happened before exchange updated so it was throwing the error. I put a sleep(20); command in the line before it rewrites the header and it works. Thanks for the help and guidance, I've learnt some useful stuff on the journey.
0
 
cescentmanAuthor Commented:
A great result thanks.
0
 
cescentmanAuthor Commented:
Sorry if this is a bit cheeky but do you have any thoughts on my other open WEBDAV question:-

http://www.experts-exchange.com/Software/Server_Software/Email_Servers/Exchange/Q_25004099.html
0
 
LeeDerbyshireCommented:
Okay, I'll have a look.
0

Featured Post

Making Bulk Changes to Active Directory

Watch this video to see how easy it is to make mass changes to Active Directory from an external text file without using complicated scripts.

  • 8
  • 8
Tackle projects and never again get stuck behind a technical roadblock.
Join Now