Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Sending Email From Access Form Button Click

Status
Not open for further replies.

StanJx

Programmer
Jun 2, 2016
29
LK
Hi I was searching for an option to send an email on a button click. I found the following code. But I am getting a compile error when I try to run the code. Please help!!


Error_ogjqoh.jpg
 
Did you make the Reference to the Outlook object?

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
Also

[tt][blue]Dim strEmail, strBody as String[/blue][/tt]

This isn't quite doing what you think it may be doing.
 
What would be the best way to do this then? I need to send an email on button click would really appreciate some help regarding this. I have to submit my project this Saturday.
 
To shed some light on what strongm is saying, you have a statement that actually says:

[tt]Dim strEmail [red]As Variant[/red], strBody as String[/tt]

It was corrected later on in the thread StanJx is mentioning in the OP

Have fun.

---- Andy

There is a great need for a sarcasm font.
 
I was able to get the below code working for me. But I am receiving an error message I have to allow every time I am sending an email. Any idea how to stop that message?

Dim mailto As String
Dim ccto As String
Dim bccto As String
mailto = "Test@test.com"
ccto = ""
bccto = ""
emailmsg = "Hi" & vbNewLine & vbNewLine & "Please find the report attached"
mailsub = "Monthly Sales Report"

DoCmd.SendObject acSendNoObject, Null, , mailto, ccto, bccto, mailsub, emailmsg, False
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top