How To Send Record via email

D

DaveM

I would like to know how best to send a few fields a newly entered data
record in an Access Table via Outlook email.

For example I would like the operator to enter/fill in a few fields in a
newly created record. I have a command button which reads "Submit" and when
they click that i would like to open a new email, populate the email with a
few of the fields (say field 1, 2 and 3) and the address populated with an
email address automatically (in the code).

I have a command button with an Event proceedure started but using the
wizard i can only get the code below to open Outlook. How might i fill in
the code for the other functionality i need? Or, is there a better way to
accomplish this?

Thanks
Dave
 
D

DaveM

Sorry,,,,here's the code i have from the wizard...

Private Sub SubmitWO_Click()

On Error GoTo Err_SubmitWO_Click

Dim stAppName As String

stAppName = "C:\Program Files\Microsoft Office\Office\OUTLOOK.EXE"
Call Shell(stAppName, 1)

Exit_SubmitWO_Click:
Exit Sub

Err_SubmitWO_Click:
MsgBox Err.Description
Resume Exit_SubmitWO_Click

End Sub
 
D

Daniel Pineault

You don't need to automate Outlook directly if you only need to send out a
text e-mail. Take a look at the sendobject method.

Something like (untested air code):

Dim sRecipient as String
Dim sSubject as String
Dim sMsg as String

sRecipient = "(e-mail address removed)"
sSubject = "E-mail Subject Line"
sMsg = "Control1 Value: " & Me.Control1Name & vbcrlf & _
"Control2 Value: " & Me.Control2Name & vbcrlf & _
"Control3 Value: " & Me.Control3Name

DoCmd.SendObject acSendNoObject,,,sRecipient,,,sSubject,sMsg,False

The last input variable control whether or not to automatically send out the
message or display it to the user so they can check it over, or edit it,
before sending.

Look up 'SendObject' in the help, or online, for more details.
--
Hope this helps,

Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples: http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.
 
A

Arvin Meyer [MVP]

Tour code will open Outlook, but that's not what you need. Instead look at:

http://www.datastrat.com/Code/OutlookEmail.txt

Pay attention to this part of the code. You want to use form references
like:

With objEmail
.To = Me.txtEmail
.Subject = "Here's the data you requested"
.body = "Field1" & Me. Field1 & vbCrLf & _
"Field2" & Me. Field2 & vbCrLf & _
"Field3" & Me. Field3
.Send
End With
--
Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com


The body does matter in your case.
 
D

DaveM

Thank you Daniel. I have a follow up. In puttig together the message body
you refer to a me.control1Name, etc. and i am having difficulty determining
how to write this for my need. I am able to get the email sent and I can get
the text string to read... ControlValue1: but i don't know how to access the
specific field value (Field Named "Employee") in a table called "WO Request".
I have various other field values and data from the record to post in this
message so if i can get some help on how to access one field's data value i
can get the rest (i think).

Thanks
DaveM
 
D

DaveM

Can someone help me with this last request? I am very appreciative of the
previous help it's just i'm in a time crunch to get this put together and i'm
a bit weak on some of this coding. Thank you in advance.

DaveM
 

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