Creating Contact Item in Personal Folder

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
 
S

Sue Mosher [MVP-Outlook]

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

Michael Steffen

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
 
S

Sue Mosher [MVP-Outlook]

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

Michael Steffen

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)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top