Categories
NETCF Windows Mobile

Contact.WebPage

The Managed APIs in Windows Mobile 5.0 expose the Contact.WebPage as a Uri. The problem with this approach is that the user forms are free text and you can enter anything into this field. Probably 9 times out of 10 you’ll enter an address such as


www.peterfoot.net


And because the managed API passes this to the Uri constructor and it has no http:// prefix it fails and returns null. However there is a solution to workaround the issue. You can access the Properties collection and access the property and it will be returned as a string. So for example you would use:-


[C#]
string webPage = session.Contacts.Items[0].Properties[Microsoft.WindowsMobile.PocketOutlook.ContactProperty.WebPage];

[VB]

Dim webPage As String = session.Contacts.Items(0).Properties(Microsoft.WindowsMobile.PocketOutlook.ContactProperty.WebPage)


If you then want to use a Uri with this value, check to see if it includes the http:// prefix and if not add your own e.g.


Uri contactsWebpage = new Uri(“http://” + webPage);


 

By Peter Foot

Microsoft Windows Development MVP