Addinf Contacts to Public Folder

O

outside123

What is the trick to added a outlook contact to a public folder? Below
is sample of the code I am trying to work with any ideas?

Dim ol As New Outlook.Application
Dim olns As Outlook.NameSpace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.ContactItem

Set ol = New Outlook.Application
Set olns = ol.GetNamespace("MAPI")
Set cf = olns.Folders("Public Folders").Folders("All Public
Folders").Folders("Contacts").Folders("ParagonTest")

With rst
..MoveFirst
' Loop through the Microsoft Access records.
Do While Not .EOF
' Create a new Contact item.
Set c = ol.CreateItem(olContactItem)
c.MessageClass = "IPM.Contact.Porini"

If ![tblSQLDATA.Name] <> "" Then c.CompanyName =
![tblSQLDATA.Name]
If ![tblSQLDATA.CONTACT] <> "" Then c.FullName = "Tony"
c.Save
..MoveNext
Loop
End With
 
O

outside123

The location of the Outlook.ContactItem ( = c) needed to be inside the
loop.

With rst
..MoveFirst
Do While Not .EOF

Set c = cf.Items.Add("IPM.Contact.Porini")
 
S

Sue Mosher [MVP-Outlook]

Don't use Application.CreateItem. Instead, use the Add method on the target
folder's Items collection:

Set c = cf.Items.Add

FYI, there is a newsgroup specifically for general Outlook programming
issues "down the hall" at microsoft.public.outlook.program_vba
 

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