Emailing from Access

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a question about Access that I was hoping someone could help me with.
I have a hyperlink on my form that when clicked, generates an email
"mailto:[email protected]?Subject=ENROLL - Intro to Insurance". I also want
to include in this email in the body, the first and last name of the person
who's record is currently open by using the "lastname" and "firstname" fields
on the form. Is this possible or is there another way of doing this?

Example:
I have the form open and I am looking at Joe Smith's Record. I click the
hyperlink on the form and outlook opens with a preaddressed email with the
subject and in the body of the email states "Please Enroll Joe Smith in Intro
to Insurance". Basically, the person using the form will just have to open
the record they want to look at, then just click the link, then send. Any
help you can give me would be greatly appreciated.
 
I think that you need create a command Botton to send e-mail like this..
___________________________________________
Private Sub mail_Click()

On Error GoTo Err_mail_Click

Dim stDocName As String
Dim stdomail As String


stDocName = "Orders" ' name of the report
stdomail = Me![SupplierID].Column(2) 'where addressee is called
DoCmd.SendObject acReport, stDocName, , stdomail, , , "Subjet bla,bla,",
"Body text bla,bla"


Exit_mail_Click:
Exit Sub

Err_mail_Click:
MsgBox Err.Description
Resume Exit_mail_Click

End Sub
 
Sure! Create a button to send the email, then in properties of the button
alter the code. For instance, if you have the control CustomerName and 2
fields you want included in the body text, you would do something like this

sub YourButton_OnCLick

dim n as string
dim f1 as string
dim f2 as string
dim msg as string

n = me.CustomerName
f1 = me.field1
f2 = me.field2

msg = "Hello " & n & ", " & vbCRLF & "Please call me regarding " & f1 & " as
soon as possible. I would also like to discuss " & f2 & ". See the attached
report for details." & vbCRLF & "Sincerely, John Doe"

DoCmd.SendObject acSendReport, "YourReportName", acFormatRTF,
"(e-mail address removed)",,,"Please Call",msg

End Sub

Assuming Customer is JB and Field1 is Widgets and Field2 is Dongles, this
would send the following email to (e-mail address removed), with the associated
Report attached as Rich Text Format:

===========
Hello JB,

Please call me regarding Widgets as soon as possible. I would also like to
discuss Dongles. See the attached report for details.
Sincerely, John Doe
==========


See the SendObject Method in VB help for more info and options on the
syntax.
 

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

Back
Top