I am attempting to write code in MSAccess to do the following in Outlook.
I've been able to write contacts to the default contact folder (Code1).
I've been able to create a new folder within the contacts folder (Code2).
What I cannot figure out how to do is create the contact items in the newly created folder. Or move them or copy them.
Any help would be much appreciated.
Thanks
= = = = = = = = =
'Code1
'= = = = =
Dim objContactItem As ContactItem
Dim snpContacts As DAO.Recordset
Set olkApp = CreateObject("Outlook.Application"
Set olkNameSpace = olkApp.GetNamespace("MAPI"
Set MyFolder = olkNameSpace.GetDefaultFolder(olFolderContacts)
Set objNewFolder = MyFolder.Folders("DIM_Folder"
Set objContactItem = olkApp.CreateItem(olContactItem)
objContactItem.FirstName = "John"
objContactItem.LastName = "Doe"
objContactItem.BusinessAddress = "1234 Main Street"
objContactItem.BusinessAddressCity = "Big City"
objContactItem.BusinessAddressState = "FL"
objContactItem.BusinessAddressPostalCode = "33026"
objContactItem.BusinessTelephoneNumber = "9544331234"
objContactItem.Email1Address = "john@doe.com"
objContactItem.Categories = "From AAA"
objContactItem.Save
Set objContactItem = Nothing
Set olkNameSpace = Nothing
Set olkApp = Nothing
MsgBox "Completed"
'Code 2
'= = = =
Set olkApp = CreateObject("Outlook.Application"
Set olkNameSpace = olkApp.GetNamespace("MAPI"
Set objFolder = olkNameSpace.GetDefaultFolder(olFolderContacts)
Set objNewFolder = objFolder.Folders.Add("MyNew_Folder"
MsgBox "Completed"
I've been able to write contacts to the default contact folder (Code1).
I've been able to create a new folder within the contacts folder (Code2).
What I cannot figure out how to do is create the contact items in the newly created folder. Or move them or copy them.
Any help would be much appreciated.
Thanks
= = = = = = = = =
'Code1
'= = = = =
Dim objContactItem As ContactItem
Dim snpContacts As DAO.Recordset
Set olkApp = CreateObject("Outlook.Application"
Set olkNameSpace = olkApp.GetNamespace("MAPI"
Set MyFolder = olkNameSpace.GetDefaultFolder(olFolderContacts)
Set objNewFolder = MyFolder.Folders("DIM_Folder"
Set objContactItem = olkApp.CreateItem(olContactItem)
objContactItem.FirstName = "John"
objContactItem.LastName = "Doe"
objContactItem.BusinessAddress = "1234 Main Street"
objContactItem.BusinessAddressCity = "Big City"
objContactItem.BusinessAddressState = "FL"
objContactItem.BusinessAddressPostalCode = "33026"
objContactItem.BusinessTelephoneNumber = "9544331234"
objContactItem.Email1Address = "john@doe.com"
objContactItem.Categories = "From AAA"
objContactItem.Save
Set objContactItem = Nothing
Set olkNameSpace = Nothing
Set olkApp = Nothing
MsgBox "Completed"
'Code 2
'= = = =
Set olkApp = CreateObject("Outlook.Application"
Set olkNameSpace = olkApp.GetNamespace("MAPI"
Set objFolder = olkNameSpace.GetDefaultFolder(olFolderContacts)
Set objNewFolder = objFolder.Folders.Add("MyNew_Folder"
MsgBox "Completed"