Programmatically adding contacts to a 'specific' folder?

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance

From: John Wiese \(MS\) (jwiese_at_microsoft.com)
Date: 02/02/05


Date: Wed, 2 Feb 2005 09:31:07 -0500

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



Relevant Pages

  • Re: Cant get code to put data into current folder
    ... Am trying to adapt your Listing 24.4 to my needs to make objContact entries ... into what is selected as Current Folder. ... objCurrentFolder in line 5 shows for sure it is at the current folder I want ... If intRowCount> 0 Then ...
    (microsoft.public.outlook.program_forms)
  • Re: Cant get code to put data into current folder
    ... CreateItem always puts items in the default folder. ... Author of Configuring Microsoft Outlook 2003 ... Am trying to adapt your Listing 24.4 to my needs to make objContact entries ...
    (microsoft.public.outlook.program_forms)
  • Re: Programmatically adding contacts to a specific folder?
    ... See the objFolder.Items.Add method where objFolder is the desired folder. ... [MVP - Outlook] ... "John Wiese " wrote in message ... > Outlook.ContactItem objContact = ...
    (microsoft.public.outlook.interop)
  • Re: Page and Images not found on Localhost
    ... I didn't know that even images could be declared as server controls. ... which may not have been declared as a server control. ... I designated the "project" folder as an application in IIS. ... is the root for anything under it. ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Virtual Directory, Paths, Local and Deployed Problem
    ... If you are looking to get to the /images folder from the root. ... In production: http://www.site1.com/images/mygif.gif ... make this a virtual folder in IIS. ...
    (microsoft.public.dotnet.framework.aspnet)