Hi JP, Sure thing.
Here is my current code. The code loops thru a public folder of contacts,
copies some of the contactItem.Properties into a Custom Object ContactItem so
I can display a grid of ContactItems:
public List<ContactItem> WcmsContactsWcmsObjects
{
get
{
List<ContactItem> Results = new List<ContactItem>();
//todo fix
//return Results;
Outlook.Items Contacts = this.WcmsContactsMapiFolder.Items;
Outlook.ContactItem Contact = (Outlook.ContactItem)
Contacts.GetFirst();
do
{
ContactItem NewCont =
ContactItem.FromOutlookContactItem(Contact, this.SifApp);
Results.Add(NewCont);
Contact = (Outlook.ContactItem)Contacts.GetNext();
} while (Contact != null);
return Results;
//int i = 1;
//foreach (Outlook.ContactItem Contact in
this.WcmsContactsOutlookObjects)
//{
// ContactItem NewCont =
ContactItem.FromOutlookContactItem(Contact, this.SifApp);
// Results.Add(NewCont);
// //Close Contact
// //Outlook._ContactItem As_ContactItem =
(Outlook._ContactItem) Contact;
//
//As_ContactItem.Close(Microsoft.Office.Interop.Outlook.OlInspectorClose.olDiscard);
// Marshal.ReleaseComObject(Contact);
// if (i > 50)
// {
// GC.Collect();
// GC.WaitForPendingFinalizers();
// GC.Collect();
// GC.WaitForPendingFinalizers();
// i = 0;
// }
// i++;
//}
return Results;
}
//Copy Outlook Data in to Custom Objects
internal static ContactItem
FromOutlookContactItem(Outlook.ContactItem Contact, FrsaSifApplication
SifAppIn)
{
ContactItem NewCont = new ContactItem();
NewCont.BusinessTelephoneNumber = Contact.BusinessTelephoneNumber;
NewCont.CompanyName = Contact.CompanyName;
NewCont.Email1Address = Contact.Email1Address;
NewCont.FileAs = Contact.FileAs;
NewCont.FirstName = Contact.FirstName;
NewCont.LastName = Contact.LastName;
if (Contact.UserProperties.Count > 0)
{
Outlook.UserProperty UserProp = Contact.UserProperties[1];
NewCont.PropertyName = UserProp.Name;
//unfortunately not support with sharepoint
if (UserProp.Type ==
Microsoft.Office.Interop.Outlook.OlUserPropertyType.olInteger)
{
NewCont.PropertyValueInt =
int.Parse(UserProp.Value.ToString());
}
else
{
SifAppIn.CommonObj.TraceThisShouldNotHappen("Unknown
Property Type", new StackFrame(true));
}
Marshal.ReleaseComObject(UserProp);
}
NewCont.EntryId = Contact.EntryID;
//NewCont.OutlookContactItem = Contact;
return NewCont;
}
The commented code was differnt attempt to "Close" the Contact
Thanks,
Mike D.