Creating Contact Item in Personal Folder

  • Thread starter Thread starter Michael Steffen
  • Start date Start date
M

Michael Steffen

Hi,

I'm trying to programtically create a New Contact Item using

Dim WithEvents m_olOutlook As Outlook.Application
Dim WithEvents m_olNamespace As Outlook.NameSpace

m_olOutlook = CType(application, Outlook.Application)



m_olNamespace = m_olOutlook.Session

m_olContactItem = m_olOutlook.CreateItem((olItemType.olContactItem))

This creates a ContactItem in the DefaultFolder and it works fine.
But now, I would like to select a personal folder using the PickFolder
dialog and create the
ContactItem in folder selected.

Can anyone give an example of how this works...

Thanks..

Michael
 
To create an item in a non-default folder, use the Add method on the target
folder's Items collection.
 
Sue,

thank you for your reply...

I've done the following:

Dim m_olContactFolder As Outlook.MAPIFolder

Dim WithEvents m_olContactItem As Outlook.ContactItem

m_olContactFolder =
m_olNamespace.GetFolderFromID(m_olNamespace.PickFolder.EntryID)

m_olContactItem =
m_olContactFolder.Items.Add(m_olOutlook.CreateItem(olItemType.olContactItem)
)

With m_olContactItem

..CustomerID = ...

..CompanyName = ...

..FirstName = ...

..LastName = ...

etc.....

..Save()

End With

But this does not work... No item is created... What's wrong?

Thanks,

Michael
 
The argument for Add is optional, but if you use it, it needs to be a
message class string, not an item type constant.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
Thanks a lot... works fine now...

Michael
The argument for Add is optional, but if you use it, it needs to be a
message class string, not an item type constant.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers




m_olContactFolder.Items.Add(m_olOutlook.CreateItem(olItemType.olContactItem)
 
Back
Top