Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Interop / February 2005

Tip: Looking for answers? Try searching our database.

Programmatically adding contacts to a 'specific' folder?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
John Wiese \(MS\) - 02 Feb 2005 14:31 GMT
I have a need to create folders under my main Contacts folder, this I have
done without a problem.  What is causing me issues is adding my new contacts
to these specific folders.  I can not find a way to add the new contact to
my specific folder.  Has anyone tried this, or know of a way to accomplish
it...here is what I am doing right now:

Outlook.ContactItem objContact = (Outlook.ContactItem)
m_OutlookApp.CreateItem(Outlook.OlItemType.olContactItem);

Outlook.MAPIFolder objContactFolder =
m_OutlookNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderContacts);

objContactFolder.Folders.Add("CoWorkers",
Outlook.OlDefaultFolders.olFolderContacts);

objContact.BusinessTelephoneNumber = workPhone.ToString();

objContact.MobileTelephoneNumber = cellPhone.ToString();

objContact.HomeTelephoneNumber = homePhone.ToString();

objContact.FullName = fullName.ToString();

objContact.FirstName = fullName.Substring(0, fullName.IndexOf("
" ) ).ToString();

objContact.LastName = fullName.Substring(fullName.IndexOf("
" ) ).ToString();

objContact.Email1Address = alias + "@Microsoft.com";

objContact.IMAddress = externalIM.ToString();

objContact.ManagerName = manager.ToString();

objContact.Department = workgroup.ToString();

objContact.CompanyName = "Company";

objContact.Categories = "Group1, Group2";

objContact.Save();

So I need some way to make the Save() put the contact in the folder I just
created and not in the root Contacts folder.

Thanks,

John Wiese
Ken Slovak - 02 Feb 2005 14:54 GMT
See the objFolder.Items.Add method where objFolder is the desired folder.

Signature

Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Absolute Beginner's Guide to Microsoft Office Outlook 2003
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm

>I have a need to create folders under my main Contacts folder, this I have
> done without a problem.  What is causing me issues is adding my new
[quoted text clipped - 46 lines]
>
> John Wiese
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.