?
Solved

Opening new contact record using URL

Posted on 2010-01-11
16
Medium Priority
?
490 Views
Last Modified: 2012-08-14
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
Comment
Question by:cescentman
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 8
  • 8
16 Comments
 
LVL 31

Expert Comment

by:LeeDerbyshire
ID: 26283421
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
 
LVL 31

Expert Comment

by:LeeDerbyshire
ID: 26283490
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
 
LVL 1

Author Comment

by:cescentman
ID: 26283746
Thanks for this. I'll try the additional entries tonight. In answer to the other question, yes the same URL.
0
Independent Software Vendors: 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!

 
LVL 31

Expert Comment

by:LeeDerbyshire
ID: 26283812
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
 
LVL 1

Author Comment

by:cescentman
ID: 26284435
Not had much success getting exchange explorer working. The version I found for download is ages old what version do you use?
0
 
LVL 31

Expert Comment

by:LeeDerbyshire
ID: 26284473
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
 
LVL 1

Author Comment

by:cescentman
ID: 26284661
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
 
LVL 31

Expert Comment

by:LeeDerbyshire
ID: 26284695
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
 
LVL 1

Author Comment

by:cescentman
ID: 26285088
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
 
LVL 31

Accepted Solution

by:
LeeDerbyshire earned 2000 total points
ID: 26288247
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
 
LVL 1

Author Comment

by:cescentman
ID: 26291025
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
 
LVL 31

Expert Comment

by:LeeDerbyshire
ID: 26292539
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
 
LVL 1

Author Comment

by:cescentman
ID: 26292892
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
 
LVL 1

Author Closing Comment

by:cescentman
ID: 31675490
A great result thanks.
0
 
LVL 1

Author Comment

by:cescentman
ID: 26292913
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
 
LVL 31

Expert Comment

by:LeeDerbyshire
ID: 26292934
Okay, I'll have a look.
0

Featured Post

Independent Software Vendors: 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!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Lotus Notes – formerly IBM Notes – is an email client application, while IBM Domino (earlier Lotus Domino) is an email server. The client possesses a set of features that are even more advanced as compared to that of Outlook. Likewise, IBM Domino is…
This article will help to fix the below errors for MS Exchange Server 2013 I. Certificate error "name on the security certificate is invalid or does not match the name of the site" II. Out of Office not working III. Make Internal URLs and Externa…
In this video we show how to create a Contact in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: First we need to log into the Exchange Admin Center. Navigate to the Recipients >> Contact ta…
In this video we show how to create a Resource Mailbox in Exchange 2013. We show this process by using the Exchange Admin Center. Log into Exchange Admin Center.: Navigate to the Recipients >> Resources tab.: "Recipients" is our default selection …
Suggested Courses

764 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question