Sending a report via e-mail

G

Guest

I created a command button to generate a report and send it via e-mail. That
part is no problem.

What I want to do is have the e-mail address of the person I'm sending it to
automatically appear in the "To" line.

Currently, the address line is blank and I have to type in the e-mail address.
 
F

fredg

I created a command button to generate a report and send it via e-mail. That
part is no problem.

What I want to do is have the e-mail address of the person I'm sending it to
automatically appear in the "To" line.

Currently, the address line is blank and I have to type in the e-mail address.

Sending the e-mail report may not be a problem for you, but how is
anyone else here supposed to know how you did it so that we can adapt
or change the method to include the e-mail address. And where would
Access get that address from?
 
G

Guest

Sorry for upsetting you...let me explain a little further...

I created a command button in a switchboard form. You click on the button
and it generates the report and attaches it to a blank e-mail.

Is there a way to include a specific e-mail address in the e-mail that is
generated?
 
R

Rick Brandt

Bill said:
Sorry for upsetting you...let me explain a little further...

I created a command button in a switchboard form. You click on the
button and it generates the report and attaches it to a blank e-mail.

But by what mechanism is it generating an Email? Is it using the SendObject
command? If so, then that has arguments for the To, the CC, the BCC, the
Subject, etc.. All you have to do is supply those values.

If you are using something besides SendObject to generate the Email then we
need to know what that method is in order to supply any information.
 
G

Guest

I used the command button wizard to create the button. Then, I selected
"report operations" and then selected "mail report"

I'm not sure if this helps....
 
F

fredg

I used the command button wizard to create the button. Then, I selected
"report operations" and then selected "mail report"

I'm not sure if this helps....

No it doesn't help.
You need to open your form in Design View. Select the command button.
Display it's property sheet. Click on the property sheet Event tab.
On the line that says On Click it will say [Event Procedure].
Click on the little button with the 3 dots that appears on that line.
When the code window opens, the cursor will be flashing within a Sub
Procedure. It will begin something like

Private Sub CommandButtonName_ClickI()
It will end, several lines down with
End Sub

Highlight and copy that entire procedure.
Paste it into a reply message and post it in this same thread.

** Also tell us how Access is going to know what the e-mail address
is. Is it stored someplace in a table? What is the actual name of the
field? ** Remember, you can see your database ... we cannot.

And I'm not upset. It's just not possible for us to know how to advise
you without getting the necessary information.
 
G

Guest

Here is the script from the "On Click":

Exit Sub

Err_Command7_Click:
MsgBox Err.Description
Resume Exit_Command7_Click

End Sub
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click

Dim stDocName As String

stDocName = "Jefferson Co Player Detail"
DoCmd.SendObject acReport, stDocName

Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End Sub

....I have one specific e-mail address that I need to send the report to. the
address is not in any table or report. I want to "hard code" the e-mail
address into the e-mail that's generated.

fredg said:
I used the command button wizard to create the button. Then, I selected
"report operations" and then selected "mail report"

I'm not sure if this helps....

No it doesn't help.
You need to open your form in Design View. Select the command button.
Display it's property sheet. Click on the property sheet Event tab.
On the line that says On Click it will say [Event Procedure].
Click on the little button with the 3 dots that appears on that line.
When the code window opens, the cursor will be flashing within a Sub
Procedure. It will begin something like

Private Sub CommandButtonName_ClickI()
It will end, several lines down with
End Sub

Highlight and copy that entire procedure.
Paste it into a reply message and post it in this same thread.

** Also tell us how Access is going to know what the e-mail address
is. Is it stored someplace in a table? What is the actual name of the
field? ** Remember, you can see your database ... we cannot.

And I'm not upset. It's just not possible for us to know how to advise
you without getting the necessary information.
 
F

fredg

Here is the script from the "On Click":

Exit Sub

Err_Command7_Click:
MsgBox Err.Description
Resume Exit_Command7_Click

End Sub
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click

Dim stDocName As String

stDocName = "Jefferson Co Player Detail"
DoCmd.SendObject acReport, stDocName

Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End Sub

...I have one specific e-mail address that I need to send the report to. the
address is not in any table or report. I want to "hard code" the e-mail
address into the e-mail that's generated.

fredg said:
I used the command button wizard to create the button. Then, I selected
"report operations" and then selected "mail report"

I'm not sure if this helps....

:

Bill wrote:
Sorry for upsetting you...let me explain a little further...

I created a command button in a switchboard form. You click on the
button and it generates the report and attaches it to a blank e-mail.

But by what mechanism is it generating an Email? Is it using the SendObject
command? If so, then that has arguments for the To, the CC, the BCC, the
Subject, etc.. All you have to do is supply those values.

If you are using something besides SendObject to generate the Email then we
need to know what that method is in order to supply any information.

No it doesn't help.
You need to open your form in Design View. Select the command button.
Display it's property sheet. Click on the property sheet Event tab.
On the line that says On Click it will say [Event Procedure].
Click on the little button with the 3 dots that appears on that line.
When the code window opens, the cursor will be flashing within a Sub
Procedure. It will begin something like

Private Sub CommandButtonName_ClickI()
It will end, several lines down with
End Sub

Highlight and copy that entire procedure.
Paste it into a reply message and post it in this same thread.

** Also tell us how Access is going to know what the e-mail address
is. Is it stored someplace in a table? What is the actual name of the
field? ** Remember, you can see your database ... we cannot.

And I'm not upset. It's just not possible for us to know how to advise
you without getting the necessary information.

Now we're cookin' <g>

Change
DoCmd.SendObject acReport, stDocName
to:

DoCmd.SendObject acSendReport, stDocName, acFormatRTF,
"(e-mail address removed)"

The next time you need to add to or change the code generated by the
wizard, open the code window and place your cursor on the method (in
this case on SendObject. Then press F1. The VBA help will open with
the arguments available. In the above code, the fourth argument is the
"To:" argument. It needs to be a string, therefore it is enclosed
within quotes.

The acFormatRTF is just one of several formats you can use. It does
not support graphics or images. The full list is available in the
SendObject help file.

Good luck.
 
G

Guest

IT WORKED!!!! THANK YOU!!!!!

fredg said:
Here is the script from the "On Click":

Exit Sub

Err_Command7_Click:
MsgBox Err.Description
Resume Exit_Command7_Click

End Sub
Private Sub Command8_Click()
On Error GoTo Err_Command8_Click

Dim stDocName As String

stDocName = "Jefferson Co Player Detail"
DoCmd.SendObject acReport, stDocName

Exit_Command8_Click:
Exit Sub

Err_Command8_Click:
MsgBox Err.Description
Resume Exit_Command8_Click

End Sub

...I have one specific e-mail address that I need to send the report to. the
address is not in any table or report. I want to "hard code" the e-mail
address into the e-mail that's generated.

fredg said:
On Tue, 22 May 2007 13:15:02 -0700, Bill wrote:

I used the command button wizard to create the button. Then, I selected
"report operations" and then selected "mail report"

I'm not sure if this helps....

:

Bill wrote:
Sorry for upsetting you...let me explain a little further...

I created a command button in a switchboard form. You click on the
button and it generates the report and attaches it to a blank e-mail.

But by what mechanism is it generating an Email? Is it using the SendObject
command? If so, then that has arguments for the To, the CC, the BCC, the
Subject, etc.. All you have to do is supply those values.

If you are using something besides SendObject to generate the Email then we
need to know what that method is in order to supply any information.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com



No it doesn't help.
You need to open your form in Design View. Select the command button.
Display it's property sheet. Click on the property sheet Event tab.
On the line that says On Click it will say [Event Procedure].
Click on the little button with the 3 dots that appears on that line.
When the code window opens, the cursor will be flashing within a Sub
Procedure. It will begin something like

Private Sub CommandButtonName_ClickI()
It will end, several lines down with
End Sub

Highlight and copy that entire procedure.
Paste it into a reply message and post it in this same thread.

** Also tell us how Access is going to know what the e-mail address
is. Is it stored someplace in a table? What is the actual name of the
field? ** Remember, you can see your database ... we cannot.

And I'm not upset. It's just not possible for us to know how to advise
you without getting the necessary information.

Now we're cookin' <g>

Change
DoCmd.SendObject acReport, stDocName
to:

DoCmd.SendObject acSendReport, stDocName, acFormatRTF,
"(e-mail address removed)"

The next time you need to add to or change the code generated by the
wizard, open the code window and place your cursor on the method (in
this case on SendObject. Then press F1. The VBA help will open with
the arguments available. In the above code, the fourth argument is the
"To:" argument. It needs to be a string, therefore it is enclosed
within quotes.

The acFormatRTF is just one of several formats you can use. It does
not support graphics or images. The full list is available in the
SendObject help file.

Good luck.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top