Apuhjee

Could someone please post some example code for creating a new JournalItem associated with a Contact   Attempting to set either the ContactNames or Companies properties is seeming to have no effect.

We have a large Access database of customers with an associated phone log that we're trying to get into Outlook.  Without the ability to programmatically link Contacts and JournalItems, we are dead in the water!

As always, any response is extremely appreciated.

Thanks ~ jp



Re: Visual Studio Tools for Office JournalItems: Adding Contacts and Companies

Apuhjee

Well - I discovered that I could set the Contacts field (in the user interface) by using the Links collection in the object model. Still can't figure out how to get a value in the "Company" UI field.

That also leaves me wondering what the "ContactNames" property is even used for

Cheers ~ jp





Re: Visual Studio Tools for Office JournalItems: Adding Contacts and Companies

John R. Durant - MSFT

It is a known issue, and we all just use the Links collection as of Outlook 2000. The ContactNames property was important and usable only in Outlook 98. It became obsolete in Outlook 2000.

Going forward, here is a list of outlook resources to help you:

http://blogs.msdn.com/johnrdurant/archive/2005/12/07/vsto_outlook_resourcelist.aspx

Best,

John






Re: Visual Studio Tools for Office JournalItems: Adding Contacts and Companies

Apuhjee

Thanks for the response and resource John. It's extremely appreciated.

I'm not really sure why you marked your post as the answer though. Maybe I'm not aware of proper etiquette in the MSDN forums, but it would seem that the person asking the question would be the one to qualify an answer... Call me crazy...

As stated in my own response, I'm aware of the Links field for adding Contacts. I now need to find a way to programmatically populate the "Company" field. Any suggestions

Regards ~ jp





Re: Visual Studio Tools for Office JournalItems: Adding Contacts and Companies

Apuhjee

The following code snippet accomplishes what I was looking for:

Outlook.ContactItem contact =
(Outlook.ContactItem)this.CreateItem(Outlook.OlItemType.olContactItem);
contact.FirstName =
"Enoch"
;
contact.LastName = "Root"
;
contact.Email1Address =
enoch@goto.com
;
contact.CompanyName = "Goto Construction"
;
contact.Categories =
"Journal Test";
contact.Save();

Outlook.JournalItem journal =
(Outlook.
JournalItem)this.CreateItem(Outlook.OlItemType
.olJournalItem);
journal.Subject =
"Phone conversation"
;
journal.Links.Add(contact);
journal.Companies = contact.CompanyName;
journal.Save();

The guidance needed was found on Sue Mosher's site:
http://www.outlookcode.com/d/code/linkcompany.htm

Cheers ~ jp