Creating a Email Message from Field

P

PosseJohn

I have a form that displays eMail address. It is displayed in a text box,
the control source is a hyperlink field in my table.

How do I create a new email message, directed to the email address, and
display the email message for further editing by the user?

Does Outlook need to be running before the email is created, or will it
start automatically?

Currently, when I click on the hyperlink, it searches for a website address,
which always fails of course.
 
D

Daniel

First get rid of the hyperlink state on the form and even the table.

Then simply create a On Double Click even for the e-mail control or add a
button with some code like:

DoCmd.SendObject acSendNoObject, , , Me.Email

Where you would replace Me.Email with your control name that has the
recipients e-mail address (Me.YourControlName).
 
D

Daniel

Forgot one important thing. The code needs a slight mod as per below

DoCmd.SendObject acSendNoObject, , , Me.Email, , , , , True

The true will allow you to see the e-mail and edit it! Kinda important
since we have not automated the subject ot content.
 
P

PosseJohn

Daniel,

If I close the email without sending it, and without editing anything in it,
I receive the following error:

"The SendObject action was cancelled."

Is there a way to trap this error?
 
D

Daniel

It raises err.number=2501 thus you need to trap that err.number. Try
something like

Function SendEmail()
On Error GoTo SendEmail_Error

DoCmd.SendObject acSendNoObject, , , "", , , , , True
If Err.Number = 0 Then Exit Function

SendEmail_Error:
If Err.Number <> 2501 Then
MsgBox "MS Access has generated the following error" & vbCrLf &
vbCrLf & "Error Number: " & _
Err.Number & vbCrLf & "Error Source: SendEmail" & vbCrLf & _
"Error Description: " & Err.Description, vbCritical, "An Error has
Occured!"
End If
Exit Function
End Function
 

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