Getting Access 2007 to send email.

KristenD

Registered User.
Local time
Today, 11:33
Joined
Apr 2, 2012
Messages
394
I am working on Access 2007 and Outlook 2010. I would like to be able to add buttons to the forms to be able to email the exports or reports. I am not having much luck searching around the internet trying to find code that would suit what I need.

I am just looking for 2 things to happen. I would like a message box to pop up asking the user if they want to email the query after it is exported to excel OR email the report that is generated. I would like both of these to happen without having to specify who the email is going to.

Right now all I have written is the Do.Cmd SendObject acOutlook.Mail
and it turns red.

Thank you!!
 
Thank you, it got me a little closer but this my first time developing a database from scratch and working with code. My only previous experience was with Access 2003 and writing queries in an already established database.

Thanks!
 
Code:
Private Sub cmdEmailRpt_Click()
Dim sRpt
sRpt = "Employee Skill Rating - Supt"
DoCmd.SendObject, ac SendReport, acPDF, sRpt,,,,Employee Skill Report,"Please review the attached reports.",,
End Sub

I am still getting an error and I followed the same exact logic that I did for the Export to Excel.

Thank you!
 
You have the syntax wrong and arguments off. There shouldn't be a space between ac and sendreport. It should be acSendReport. Your 2nd argument acPDF should be the third argument. nd shouldbe the report name.
Code:
 Docmd.Sendobject acSendReport, "reportname", acFormatPDF

See this link. http://msdn.microsoft.com/en-us/library/ff197046.aspx
 
I would recommend a bit of work on your search skills. When you have a problem, ask yourself "IS my problem unique or perhaps other people have the same problem". Every 10th or 20th post on AWF Forms or VBA forums concerns emailing. Use the forum's search button. Or else use google:
email report site:www.access-programmers.co.uk
this will restrict the Google search to AWF and give you hundreds of posts.

With syntax problems the first thing to do is to look up the function/command/method in the documentation. In your code, select the thing and press F1.

Use AWF as a source of illumination, not as a crutch, for work that you could do yourself.

One final item: Intellisense. When you type a function/method in Access code window it shows you what it expects to follow, and offers choices on many occasions. Type slowly and see what pops up.
 

Users who are viewing this thread

Back
Top Bottom