Categories
NETCF Windows Mobile

Issue with Microsoft.WindowsMobile.PocketOutlook.RecipientCollection.Add()

When you want to create a meeting request with managed POOM on WM5.0 you start by creating an Appointment and then add Recipient objects to it’s Recipients collection. However what the documentation doesn’t tell you is that you have to ensure that your Recipient has both the Name and Address properties. For example:-


Microsoft.WindowsMobile.PocketOutlook.Appointment ma = new Microsoft.WindowsMobile.PocketOutlook.Appointment();
ma.Subject = “Test 5”;
ma.Recipients.Add(new Microsoft.WindowsMobile.PocketOutlook.Recipient(“user@yourdomain.com));


Will throw a Win32Exception with the text “Native method call failed”. This isn’t very descriptive but the reason it fails is due to how native POOM works – the IRecipients.Add method takes a name argument and since your Name property is empty this call fails. If you specify the name e.g.


ma.Recipients.Add(new Microsoft.WindowsMobile.PocketOutlook.Recipient(“User”,”user@yourdomain.com));


or even this if you only have an address:-


ma.Recipients.Add(new Microsoft.WindowsMobile.PocketOutlook.Recipient(user@yourdomain.com,”user@yourdomain.com));


Then you’ll be okay.

By Peter Foot

Microsoft Windows Development MVP