Using VBA for Outlook and VBA for Access within Access

S

Sardonic

I have an access application which is successfully calling the following VBA
procedures:

1) ns.Logon
2) stDocName = "Client Activity"
DoCmd.OpenForm stDocName, , , stLinkCriteria

However, the following procedure throws a compile error, "Method or Data
Member not found" - and highlights the .CreateItem method. What shall I do
to make this code work - I've adapted from VBA for Absolute beginners.
(p230-235) I have added the Outlook 11.0 library as a referece to my copy of
access.


Dim ol As Outlook.Application
Dim ns As NameSpace
Dim msg As MailItem

Set ol = CreateObject("Outlook.Application")
Set ns = ol.GetNamespace("MAPI")

ns.Logon

Set msg = Application.CreateItem(olMailItem)

With msg
.Receipents.Add "email 1"
.Recipients.Add "email 2"
.Subject = "test1"
.Body = "This is a test"
End With

ns.Logoff
 
S

Sue Mosher [MVP-Outlook]

You need to use the Outlook.Application object you created, not the Access Application object:

Set msg = ol.CreateItem(olMailItem)

--
Sue Mosher, Outlook MVP
Author of Configuring Microsoft Outlook 2003

and Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top