![]() |
Using VBA for Outlook and VBA for Access within Access
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 |
Using VBA for Outlook and VBA for Access within Access
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 http://www.turtleflock.com/olconfig/index.htm and Microsoft Outlook Programming - Jumpstart for Administrators, Power Users, and Developers http://www.outlookcode.com/jumpstart.aspx "Sardonic" wrote in message ... 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 |
All times are GMT +1. The time now is 05:30 AM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com