A Microsoft Outlook email forum. Outlook Banter

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.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Using VBA for Outlook and VBA for Access within Access



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old March 17th 06, 11:27 AM posted to microsoft.public.outlook.program_vba
Sardonic
external usenet poster
 
Posts: 1
Default 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



Ads
  #2  
Old March 17th 06, 12:34 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default 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



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
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 05:30 PM
Delete Custom Outlook Control thru Access VBA Sue Mosher [MVP-Outlook] Outlook - Using Forms 0 January 20th 06 05:29 PM
Tough One - Update Pivot Chart in Access Report using VBA? jer99 Outlook and VBA 2 January 19th 06 10:29 PM
Running query from Access Form commmand using VBA code Berny Outlook and VBA 4 January 16th 06 02:12 PM
List of Outlook References Through VBA David Outlook - General Queries 0 January 10th 06 11:53 PM


All times are GMT +1. The time now is 10:35 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2024 Outlook Banter.
The comments are property of their posters.