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

E-mail from an Access 2000 form field

Status
Not open for further replies.

mjmurray

Technical User
Jun 17, 2002
4
GB
Hi all, can anybody tell me the solution (if there is one) to how to send an e-mail from an access form by simply clicking on the email address field, so that the name automatically appears in the to: line of outlook.

thanks in anticipation.
 
The first set of code below is the procedure for this, the second is the exact copy of one that I am using so you can see a true working example.....I bolded the section you will need to put the field for the email address into.....also, check out the help file on the DoCmd.SendObject or let me know if you have any more questions.....

DoCmd.SendObject , , acFormatRTF, Me![txtEmail].Value, , , What you want to be on the subject line, If you want a default body of tet to appear, False



DoCmd.SendObject , , acFormatRTF, Me![txtEmail].Value, , , "Work Order #" _
& Me![txtWO#].Value & " - " & Me![txtSummary].Value, "Dear " & Me![cboUser].Value _
& "," & vbCrLf & vbCrLf & "We have received your work order request. " _
& Me![cboResponsible].Value & " has been assigned to handle your issue. It has been " _
& "logged into our tracking system as a Severity " & Me![txtPriority].Value & " and " _
& "should be completed no later than " & Me![txtDueDate].Value & ". If you have any " _
& "questions, please contact the Help Desk by e-mail and include the work order number " _
& "in the subject line." & vbCrLf & vbCrLf & "Thank You" & vbCrLf & "Help Desk" & vbCrLf _
& "x1357", False
It's not important that someone else can do in one step what it took you ten to do...the important thing is that you found a solution. [spin]

Robert L. Johnson III, A+, Network+, MCP
Access Developer/Programmer
 
This is a little prettier than Rob's (no offense)... it requires a reference to Outlook...

Hope this helps... Kevin

Public Sub CreateOLMailItem(strRecipient As String, strSubject As String, _
strBody As String, Optional strAttachment As String)

Dim olkApp As Outlook.Application
Dim olkNameSpace As Outlook.NameSpace
Dim objMailItem As Outlook.MailItem

Set olkApp = New Outlook.Application
Set olkNameSpace = olkApp.GetNamespace("MAPI")
Set objMailItem = olkApp.CreateItem(olMailItem)

With objMailItem
.To = strRecipient
.Recipients.ResolveAll
.Subject = strSubject
If strAttachment <> &quot;&quot; Then .Attachments.Add strAttachment
.Body = strBody
'Note: You can comment out the next line if you want the email to be sent without displaying it.
.Display
.Send
End With

Set objMailItem = Nothing
Set olkNameSpace = Nothing
Set olkApp = Nothing

End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top