D
Dave F
I am trying to export custom fields from Outlook 2003 using Access 2003 and
VBA (see full code below).
How can I reference a specific public folder in VBA?
I can reference my personal outlook folder as:
Set cf = olns.GetDefaultFolder(olFolderContacts)
This works fine. But I need to access a public folder.
I can change the setting to this:
Set cf = olns.GetDefaultFolder(olPublicFoldersAllPublicFolders)
But I get an empty result set.
How can I reference a _specific_ public folder in VBA?
Here is my full code:
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("_TestImport")
Dim ol As New Outlook.Application
Dim olns As Outlook.Namespace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.ContactItem
Dim objItems As Outlook.Items
Dim Prop As Outlook.UserProperty
Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetDefaultFolder(olFolderContacts)
Set objItems = cf.Items
iNumContacts = objItems.Count
If iNumContacts <> 0 Then
For i = 1 To iNumContacts
If TypeName(objItems(i)) = "ContactItem" Then
Set c = objItems(i)
rst.AddNew
'standard properties
rst![Company] = c.CompanyName
'custom properties
'rst!ISP = c.UserProperties("ISP")
rst.Update
End If
Next i
rst.Close
VBA (see full code below).
How can I reference a specific public folder in VBA?
I can reference my personal outlook folder as:
Set cf = olns.GetDefaultFolder(olFolderContacts)
This works fine. But I need to access a public folder.
I can change the setting to this:
Set cf = olns.GetDefaultFolder(olPublicFoldersAllPublicFolders)
But I get an empty result set.
How can I reference a _specific_ public folder in VBA?
Here is my full code:
Dim rst As DAO.Recordset
Set rst = CurrentDb.OpenRecordset("_TestImport")
Dim ol As New Outlook.Application
Dim olns As Outlook.Namespace
Dim cf As Outlook.MAPIFolder
Dim c As Outlook.ContactItem
Dim objItems As Outlook.Items
Dim Prop As Outlook.UserProperty
Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetDefaultFolder(olFolderContacts)
Set objItems = cf.Items
iNumContacts = objItems.Count
If iNumContacts <> 0 Then
For i = 1 To iNumContacts
If TypeName(objItems(i)) = "ContactItem" Then
Set c = objItems(i)
rst.AddNew
'standard properties
rst![Company] = c.CompanyName
'custom properties
'rst!ISP = c.UserProperties("ISP")
rst.Update
End If
Next i
rst.Close