Addinf Contacts to Public Folder

  • Thread starter Thread starter outside123
  • Start date Start date
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
 
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")
 
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
 
Back
Top