Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

How can I send a mail from a form directly to e-mail address

0 views
Skip to first unread message

Marco

unread,
Mar 2, 2007, 11:52:17 AM3/2/07
to
Hi,

Is it possible to send e-mails from a form?

Imagine this, I have a form with some data into and I would like to press a
button and send that data directly to a e-mail address. Can I do it? HOW?

Best Regards,
Marco

MikeJohnB

unread,
Mar 3, 2007, 1:08:05 PM3/3/07
to
Yes, you can send e mail direct from a form but your question does not
clarify what you want to send?

Look up
DoCmd.SendObject acForm, ,

Sends the form details to e mail but I don't think you really want to do
this because the form info does not very clever.

Its much better to send an e mail based on a report from your form. The
report should be based on the same query as you form which means it will be
displaying the same data as the form when you press send e mail.

To send an e mail, I have generated a send e mail button using the wizard.
(Report Operation\Send Mail)The code for sending the report will be generated
as below.

Private Sub Command142_Click()
On Error GoTo Err_Command142_Click

Dim stDocName As String

stDocName = "YourReportName" 'the report you selected to be sent
DoCmd.SendObject acReport, stDocName

Exit_Command142_Click:
Exit Sub

Err_Command142_Click:
MsgBox Err.Description
Resume Exit_Command142_Click

End Sub

You can modify this code to send specifically to recipients names taken from
controls etc.

My code looks like this

Private Sub SendEMailButton_Click()
On Error GoTo Err_SendEMailButton_Click

Dim stDocName As String
Dim StrTo As String
Dim StrSubject As String
Dim Pge As String
Dim stLinkCriteria As String

StrTo = DLookup("[E_Mail_Address]", "[Tbl_Contact]", "[Contact]='" &
Forms![frm_general_enquiries]![ContactCombo95] & "'")'looks up the name to
send to based on a control on the form being sent from

stDocName = "Rprt_Quote_By_E_Mail" 'The report I am sending (Contains
the same information as the form being viewed in real time.

DoCmd.SendObject acReport, stDocName, To:=StrTo, Subject:="Our Quotation
Ref " & Me.Reference_No 'Our Quotation ref is my tittle can also be based on
a control source if required

Exit_SendEMailButton_Click:
Exit Sub

Err_SendEMailButton_Click:
If StrTo = "" Then 'if there is no e mail address on the form, send error
MsgBox "You have NO E MAIL ADDRESS to send to???????"
Exit Sub
End If
MsgBox Err.Description
Resume Exit_SendEMailButton_Click

End Sub

I hope this at least points you in the right direction. The Method used
above will send to the default e mail agent you have set up, ie Outlook
Express, Outlook or Lotus notes what ever is set as you default e mail
method. It is always best to send snapshot format because the report
formatting is maintained.

Hope this helps

Mike B

--
Advice to Posters.
Mark as answered when completed.

Check your post for replies or request for more information.

Have the COURTESY to send an ending note even if the answer didn''t work.

Marco

unread,
Mar 4, 2007, 11:22:21 AM3/4/07
to

Marco

unread,
Mar 4, 2007, 11:25:46 AM3/4/07
to
Hi. Thank you very much for your post. I'll try to do this. If I still have
some doubts
can you send me an quick example??

Thanks once again.

Marco

MikeJohnB

unread,
Mar 4, 2007, 1:52:38 PM3/4/07
to
Yes, If necessary, I will provide you with a sample. But it might be better
for you to zip you database and send it to me. e mail as name @hotmail.com
Make Subject Access Database

--
Advice to Posters.


Check your post for replies or request for more information.

Consider providing some feed back to the response you have recieved.
Kindest Regards Mike B

Marco

unread,
Mar 23, 2007, 3:31:03 PM3/23/07
to
Hi. long time from our last post.

Thanks, your help was very helpful.

I put it work with your help. but, Is any way to control the Send? well what
I mean is, when I press the button, it asks for the type of file that I want
to export and then opens Outtlok and I have to press Send.

Can I tell to access that the default type to export is Snapshot and send
with I have to press Send button of outlook?

Best Regards,
Marco

0 new messages