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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Emailing proposals to customers through access using a button

Status
Not open for further replies.

catinreno

Technical User
Feb 18, 2010
4
US
Hi,

I am new at this so please bear with me. I am working on an already created DB in Access that was not completely set up. The company wanted a button on a form to be clicked where it would take the information from the proposal and send the proposals to the customer when clicked.

Currently the code in VB reads as this:

Private Sub cmdSendEmail_Click()
Dim sEmail As String

If Not IsNull(Me!Email) Then sEmail = Me!Email
OpenEmailProgram sEmail, "Job Proposal", "Please see attached job proposal.", "", ""

End Sub
---------------------

When the button is clicked, Outlook opens and sets up the email with the correct customer email (I'm assuming it is pulling the email from a form), along with the words in the subject, "Please see attached job proposal." However, there is no attached proposal.

I've looked around and found something that seemed to work, except that it won't pull the email address from the form. Here's the other code I used that attached the form, but didn't put in the email:

DoCmd.SendObject _
acSendReport, _
"rptProposal", _
acFormatRTF, _
False
--------------------------

I placed this code into the other code as follows:

Private Sub cmdSendEmail_Click()
Dim sEmail As String

DoCmd.SendObject _
acSendReport, _
"rptProposal", _
acFormatRTF, _
False

If Not IsNull(Me!Email) Then sEmail = Me!Email
OpenEmailProgram sEmail, "Job Proposal", "Please see attached job proposal.", "", ""

End Sub
----------------

Like I mentioned, it worked, except that it didn't input the email address. And I am also getting an error code and it wants me to degub. I don't know VB, but with my HTML, JS & CSS knowledge, I was able to figure out some of it to get me this far.

Any ideas how we can do this? The programmer who originally set this up is no longer doing Access programming. ACK! Any help (in language I can understand) would be great! I saw the thread: thread702-396121 and it didn't really help me out too much except that nat1967 looked really helpful, so if you want to help me out nat, I'd be really greatful!!

Thanks!!
 
Hi Ruralguy,

I have read this page before and it explains how to have Access attach the report, but it doesn't explain how to have Access pull the correct customer email for each report I want to send. So it doesn't really help me. Any other suggestions?
 
The email address is on the same form as the code you posted. That's what the Me!Email points to.

(RG for short) aka Allan Bunch MS Access MVP acXP, ac07 - winXP Pro, Win7 Pro
Please respond to this forum so all may benefit
 
Put the cursor inside the word SendObject in your code and then press the F1 key.

Hope This Helps, PH.
FAQ219-2884
FAQ181-2886
 
Hi RuralGuy: The thing is, I want it to BOTH enter the correct email AND attach the report. Right now it is not doing both. It does either one or the other. The code I pasted in gives me an error and wants to debug. If you can tell me why, I might be able to fix it so they both work. Thanks.

Hi PHV: Thanks for your response as well. I will try this too.
 
What error are you getting and when you go to debug, what is the line of code that is highlighted?

(RG for short) aka Allan Bunch MS Access MVP acXP, ac07 - winXP Pro, Win7 Pro
Please respond to this forum so all may benefit
 
Hi RG, it's giving me a run-time error '2293' and says it can't send this e-mail message. When I click debug, it shows this part of the code highlighted in yellow.

DoCmd.SendObject _
acSendReport, _
"rptProposal", _
acFormatRTF, _
False

Before, depending on where I put it in the code, it would give me the same error, but still create an email with the correct attachment, but no email in the "to" box. Now it doesn't want to do that anymore...

Thanks for all your help!
 
PHV hit the nail on the head. You need to put the SendObject in the correct format. Go back and read his suggestion and then give his suggestion a try.

(RG for short) aka Allan Bunch MS Access MVP acXP, ac07 - winXP Pro, Win7 Pro
Please respond to this forum so all may benefit
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top