![]() |
If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below. |
|
|
Thread Tools | Search this Thread | Display Modes |
#1
|
|||
|
|||
![]()
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 |
Ads |
#2
|
|||
|
|||
![]()
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 |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
VBA Code to put in Access that will send an Email with Attachments | [email protected] | Outlook and VBA | 1 | April 9th 06 06:30 PM |
Delete Custom Outlook Control thru Access VBA | Sue Mosher [MVP-Outlook] | Outlook - Using Forms | 0 | January 20th 06 06:29 PM |
Tough One - Update Pivot Chart in Access Report using VBA? | jer99 | Outlook and VBA | 2 | January 19th 06 11:29 PM |
Running query from Access Form commmand using VBA code | Berny | Outlook and VBA | 4 | January 16th 06 03:12 PM |
List of Outlook References Through VBA | David | Outlook - General Queries | 0 | January 11th 06 12:53 AM |