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

Email using fields in Access 1

Status
Not open for further replies.

schltzy99

Programmer
Feb 11, 2002
33
US
Hi, I am rather new to some of the functions of MSAccess.

Is it possible to create a module that will fire off when a form is submitted that will pull an email address from a field in the form and using that email address send an email to that person?

The email would pull its subject and body from a table. This table would have a primary key, EID. Can I have it pull a specific EID based on what form they hit submit on?

I know this is a lot to ask, but any help would be greatly appreciated.

Thank you!
 
Sure, you can do all of this through the DoCmd.SendObject command. You would simply create a vatriable for the email address and feed this into the SendObject command, along with your other fields....Check out the help files and then let me know if you need anymore assistance. Below is an example of a call center email I set up....

DoCmd.SendObject , , acFormatRTF, Me![txtEmail].Value, , , "Completed Work Order #" _
& Me![txtWO#].Value & " - " & Me![txtSummary].Value, "Dear " & Me![cboUser].Value _
& "," & vbCrLf & vbCrLf & "Your work order request is complete." & vbCrLf & vbCrLf _
& "Problem:" & vbCrLf & Me![memDescription].Value & vbCrLf & vbCrLf & "Solution:" _
& vbCrLf & Me![memResolution].Value & vbCrLf & vbCrLf & "If you further assistance, " _
& "please contact the Help Desk at x1357." & vbCrLf & vbCrLf & "Thank You." & vbCrLf _
& Me![cboResponsible].Value, False Programming isn't a profession of choice.
It's a profession of calling...
"Hey Programmer, your application broke again!" [spin]

Robert L. Johnson III, A+, Network+, MCP
robert.l.johnson.iii@ssmb.com
 
Mstrmage, I am sorry, but I do not fully understand what this code does? Does it pull the email from the form? What does it use to send the email? It doesnt look like there is a subject or body there? I could be wrong though.

Again, thanks for your help!

RSchultz
**Access 2000**
 
FSDInc,
Here is gthe breakdown...I put each section on it's own line.

DoCmd.SendObject _ ' The command to send the mail
, _ ' I left the section blank. By
' default it supplements
' acSendNoObject
, _ ' Again left blank. Would
' be object name.
acFormatRTF, _ ' Send the file using .rtf
' format to try to preserve any
' formatting.
Me![txtEmail].Value, _ ' This is the textbox on my
' form that holds the email
' address
, _ ' Left blank. The CC Field
, _ ' Left blank. The BCC Field
"Completed Work Order #" _
& Me![txtWO#].Value & " - " & Me![txtSummary].Value, _ ' This sectionn is the subject
' line. Mine was a combination
' of some text boxes on my form.
"Dear " & Me![cboUser].Value _
& "," & vbCrLf & vbCrLf & "Your work order request is complete." & vbCrLf & vbCrLf _
& "Problem:" & vbCrLf & Me![memDescription].Value & vbCrLf & vbCrLf & "Solution:" _
& vbCrLf & Me![memResolution].Value & vbCrLf & vbCrLf & "If you further assistance, " _
& "please contact the Help Desk at x1357." & vbCrLf & vbCrLf & "Thank You." & vbCrLf _
& Me![cboResponsible].Value,
_ ' This whole block is the body.
' Again a combination of a series
' of text boxes from my form.
False ' This last just says send the
' mail immediately. If you set
' this to true, you will see the
' message and have to click the
' send button to actually send
' it.

I hope this makes it a bit clearer.....Here si teh exact syntax from the help file...

DoCmd.SendObject [objecttype][, objectname][, outputformat][, to][, cc][, bcc][, subject][, messagetext][, editmessage][, templatefile]

Please let me know if I can help more... Programming isn't a profession of choice.
It's a profession of calling...
"Hey Programmer, your application broke again!" [spin]

Robert L. Johnson III, A+, Network+, MCP
robert.l.johnson.iii@ssmb.com
 
Thank you,

That is much clearer for the inept, such as me! I really appreciate your help.

I will let you know if I need any further assistance.

Thanks again!

RSchultz
**Access 2000**
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top