Today, It took me a while to develop a program that can create and modify a Contact file in Windows Mobile 6.5.
If you are not clear how to use PocketOutlook class in Windows Mobile, then continue to read:
1 . add a Namespace and Assembly reference(like most C# programs):
using Microsoft.WindowsMobile.PocketOutlook;
2. Make an instance of class OutlookSession and setup parameters.
OutlookSession mySession = new OutlookSession();
Contact con = mySession.Contacts.Items.AddNew();
con.MobileTelephoneNumber = “11111111″;
con.FileAs = “name”;
con.SetPicture(“filenamehere”);
con.Email1Address=”youremail@email”;
con.Update();
3. Modify an existing contact using a “for” loop
(please note here: foreach loop can not be used for modifying contacts in Windows Mobile)
for (int i = 0; i < collection.Count; i++)
{
Contact c = collection[i];
if (c.FileAs == “leon”)
{
c.MobileTelephoneNumber = i.ToString() + “1111″;
c.BusinessAddressStreet = i.ToString() + “dfdfd”;
c.SetPicture(loc);
c.Update();
}
}
Hope that helps! I also managed to download image files from other sites and save them to mobile storage, this can be useful for adding contact pictures.
