Email Button Code

bpgolferguy

Active Member
Joined
Mar 1, 2009
Messages
469
Hi, I have created a button in Access that when clicked I would like it to email the respective report to a group of email addresses. I used the wizard to do this, but I would like it a little more automated. Here is what the code is currently:

Code:
Private Sub Email_Phone_Center_Click()
On Error GoTo Err_Email_Phone_Center_Click
    Dim stDocName As String
    stDocName = "Phone Center Report"
    DoCmd.SendObject acReport, stDocName
Exit_Email_Phone_Center_Click:
    Exit Sub
Err_Email_Phone_Center_Click:
    MsgBox Err.Description
    Resume Exit_Email_Phone_Center_Click
    
End Sub

After I click the button, it first asks what type of file to send. I always want to send the reports as an .rft file, so if that can be automated into the code that would be great. Next, it opens an email message and attaches the file. What I would like to do here is add a couple of email addresses into the code so they prefill, along with a prefilled subject line and a small message in the body. I still want the email message to show instead of automatically send....just in case something needs to be modified.

Does anyone know how I can change that code to do what I need? Thank you!
 

Excel Facts

Copy a format multiple times
Select a formatted range. Double-click the Format Painter (left side of Home tab). You can paste formatting multiple times. Esc to stop
Take a look at the macro section in your Access Database, there is an option there to use Send Object and you can then select the report and also as rtf as the output and then adjust various options, once you have completed this you can then open a form in design view drag the macro onto the form, then use the convert macro to VBA to get the code with Error Handling.
 
Upvote 0

Forum statistics

Threads
1,224,507
Messages
6,179,176
Members
452,893
Latest member
denay

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top