Sending emails via access

R

RickSonea

Hello,
How can i set up a macro to open up outlook and automatically have the email
address populated from a list I have in a table?
 
R

RickSonea

Hello Arvin,
I have already created a table that has the list without any nulls, where
would i input that information into the code so it knows to pull from that
table?
THanks,
 
R

RickSonea

I entered that code into a module and in my macro i selected run code an for
the function name i put the name of the module i.e Email ( ). But i get an
error " the expression you entered has a function name that Microsoft Access
can't find". Is there an easier way to do this? Maybe create it in a form?
Thanks for the help.
 
A

Arvin Meyer [MVP]

You must name the module differently than the function. Access has no way of
knowing which is which. The code you need to run also has 4 arguments, 1 of
which comes from your table list, 1 comes from the form or is hard coded,
and the other 2 are optional (body and attachment) but they must come from a
form or be filled in:

Email(strTo As String, strSubject _
As String, Optional varMsg As Variant, Optional varAttachment As
Variant)

Don't use a macro to call your code. Macros are too limited to use anything
like this. Call it in the click event of a command button with an [Event
Procedure] by simply using the Call keyword:

Call Email(strTo, Me.txtSubject, Me.txtMessage)

--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com
 
Top