Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSAccess to Outlook

Status
Not open for further replies.

MyerK

Programmer
Mar 23, 2002
18
US
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"

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top