G
GL
I'm using the following code in an attempt to add
names/email addresses to a test group under my contacts
folder. I'm able to add to the contacts folder just not
the test group under it. I added a couple lines due to
someones help, and it seems right but I'm getting an error
message (Operation Failed. Object could not be found.),
so I'm thinking I'm missing something else. I don't code
as much as I should so its very possible I'm missing
something. Any suggestions would be very appreciated!!
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 the error message falls
Set cfsub = cf.Folders.Item("Test")
With rst
.MoveFirst
'Loop through the records.
Do While Not .EOF
' Create a New Contact item.
Set c = ol.CreateItem(olContactItem)
'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
names/email addresses to a test group under my contacts
folder. I'm able to add to the contacts folder just not
the test group under it. I added a couple lines due to
someones help, and it seems right but I'm getting an error
message (Operation Failed. Object could not be found.),
so I'm thinking I'm missing something else. I don't code
as much as I should so its very possible I'm missing
something. Any suggestions would be very appreciated!!
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 the error message falls
Set cfsub = cf.Folders.Item("Test")
With rst
.MoveFirst
'Loop through the records.
Do While Not .EOF
' Create a New Contact item.
Set c = ol.CreateItem(olContactItem)
'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