Chazelle Consulting Services  

 

Your Microsoft Access Specialists  

Home
Resources
References
Contact us




 

























































Email from Access
 

To email directly from Access, use the following steps:

1. Create a text field called "email".

2. On a form, put a text control with the email field

3. Create a button called "EmailCmd" that will start Outlook when clicked; Write the following code to its OnClick property:

Private Sub EmailCmd_Click()
On Error GoTo HandleErr
If Me.Dirty Then DoCmd.RunCommand acCmdSaveRecord
EnableEmail
ExitHere:
Exit Sub
HandleErr:
Select Case Err
Case Else
MsgBox Err & ": " & Err.Description, "Form_allContacts.Emailcmd_Click"
End Select
Resume ExitHere
End Sub

4. Write the following code to the OnCurrent property of the form itself:

Private Sub Form_Current()
On Error Resume Next
EnableEmail
End Sub

5. Add the following code anywhere in the VB window for the form:

Private Sub EnableEmail()
On Error Resume Next
EmailCmd.HyperlinkAddress = "mailto: " & Me!Email
End Sub

When you click on the button, it should start Outlook and put the email address in the "To" line.

Note: I only tested this code with Outlook. I am not sure whether it would work with any other email program, although I think it would.