G
GL
Hi,
I have a module that takes email addresses from an Access
table and creates them in a subfolder in Outlook. I had
it working on my machine at home with Access 2000 and
Outlook 2000. When I reference the subfolder in Access
2002 and Outlook 2002 I get the error An operation
failed. An object could not be found. The folder is
definitely there! It will add if I just do it to the
default contacts folder but not to the subfolder. PLEASE
HELP!! I'm thinking it may be a referencing issue, but
I'm really stuck.
The following is the code:
Sub ExportAccessContactsToOutlook()
'Used the following when using DAO dbase Need DAO 3.6 Lib
' Dim ODataBase As DAO.Database
'Dim rst As DAO.Recordset
'Set ODataBase = OpenDatabase("c:\Client
Systems\YMCA\EmailTest")
'Set rst = ODataBase.OpenRecordset("tblMember")
'Set up Objects
Dim MyDB As Database
Dim rst As Recordset
Set MyDB = CurrentDb
Set rst = MyDB.OpenRecordset("qryAC")
'Set up Outlook Objects.
Dim ol As New Outlook.Application
Dim olns As Outlook.NameSpace
Dim cf As Outlook.MAPIFolder
Dim cfsub As Outlook.MAPIFolder
Dim c As Outlook.ContactItem
Dim Prop As Outlook.UserProperty
Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetDefaultFolder(olFolderContacts)
'The following line is where debug gets stuck.
Set cfsub = cf.Folders.Item("APDTest")
With rst
.MoveFirst
'Loop through the records.
Do While Not .EOF
' Create a New Contact item.
Set c = cfsub.Items.Add
' Set c = cf.Items.Add
'specify which outlook form to use
c.MessageClass = "IPM.Contact"
'create all built-in Outlook fields
If ![ContactName] <> " " Then c.FullName = !
[ContactName]
If ! <> " " Then c.Email1Address = ![Email]
c.Save
' c.Close
.MoveNext
Loop
End With
End Sub
THANKS for any info you could pass my way!!!
Gina
I have a module that takes email addresses from an Access
table and creates them in a subfolder in Outlook. I had
it working on my machine at home with Access 2000 and
Outlook 2000. When I reference the subfolder in Access
2002 and Outlook 2002 I get the error An operation
failed. An object could not be found. The folder is
definitely there! It will add if I just do it to the
default contacts folder but not to the subfolder. PLEASE
HELP!! I'm thinking it may be a referencing issue, but
I'm really stuck.
The following is the code:
Sub ExportAccessContactsToOutlook()
'Used the following when using DAO dbase Need DAO 3.6 Lib
' Dim ODataBase As DAO.Database
'Dim rst As DAO.Recordset
'Set ODataBase = OpenDatabase("c:\Client
Systems\YMCA\EmailTest")
'Set rst = ODataBase.OpenRecordset("tblMember")
'Set up Objects
Dim MyDB As Database
Dim rst As Recordset
Set MyDB = CurrentDb
Set rst = MyDB.OpenRecordset("qryAC")
'Set up Outlook Objects.
Dim ol As New Outlook.Application
Dim olns As Outlook.NameSpace
Dim cf As Outlook.MAPIFolder
Dim cfsub As Outlook.MAPIFolder
Dim c As Outlook.ContactItem
Dim Prop As Outlook.UserProperty
Set olns = ol.GetNamespace("MAPI")
Set cf = olns.GetDefaultFolder(olFolderContacts)
'The following line is where debug gets stuck.
Set cfsub = cf.Folders.Item("APDTest")
With rst
.MoveFirst
'Loop through the records.
Do While Not .EOF
' Create a New Contact item.
Set c = cfsub.Items.Add
' Set c = cf.Items.Add
'specify which outlook form to use
c.MessageClass = "IPM.Contact"
'create all built-in Outlook fields
If ![ContactName] <> " " Then c.FullName = !
[ContactName]
If ! <> " " Then c.Email1Address = ![Email]
c.Save
' c.Close
.MoveNext
Loop
End With
End Sub
THANKS for any info you could pass my way!!!
Gina