PC Review
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Using VBA for Outlook and VBA for Access within Access
Forums
Newsgroups
Microsoft Outlook
Microsoft Outlook VBA Programming
Using VBA for Outlook and VBA for Access within Access
![]() |
Using VBA for Outlook and VBA for Access within Access |
|
|
Thread Tools | Rate Thread |
|
|
#1 |
|
Guest
Posts: n/a
|
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 |
|
|
|
#2 |
|
Guest
Posts: n/a
|
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" <Sardonic@discussions.microsoft.com> wrote in message news:42FBFD14-BE7B-4013-AFAB-61C5DEA5A53A@microsoft.com... >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 > > > |
|
![]() |
|
| Thread Tools | |
| Rate This Thread | |
|
|

Main Page 

