Hi.
You can use a hyperlink to open your default mail client, presumably
Outlook, with the copied E-mail address and the subject line, if there is
one. And you don't need to double-click. A single click will do.
In the following example, txtEMail is the text box holding the desired
E-mail address, txtSubject is the text box holding the subject line for this
new E-mail, and lblUnattached is the name of the unattached label for the
hyperlink. The three required subroutines are Form_Current( ),
txtEMail_AfterUpdate( ), and txtSubject_AfterUpdate( ).
' * * * * Start code * * * *
Private Sub Form_Current()
On Error GoTo ErrHandler
If (Nz(Me!txtEMail.Value, "") <> "") Then
If (Nz(Me!txtSubject.Value, "") <> "") Then
Me!lblUnattached.HyperlinkAddress = "Mailto:" &
Me!txtEMail.Value & _
"?Subject=" & Me!txtSubject.Value
Else
Me!lblUnattached.HyperlinkAddress = "Mailto:" & Me!txtEMail.Value
End If
Me!lblUnattached.Caption = "Mailto:" & Me!txtEMail.Value
Else
Me!lblUnattached.HyperlinkAddress = ""
Me!lblUnattached.Caption = ""
End If
Exit Sub
ErrHandler:
MsgBox "Error in Form_Current( ) in " & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear
End Sub ' Form_Current( )
Private Sub txtEMail_AfterUpdate()
On Error GoTo ErrHandler
If (Nz(Me!txtEMail.Value, "") <> "") Then
If (Nz(Me!txtSubject.Value, "") <> "") Then
Me!lblUnattached.HyperlinkAddress = "Mailto:" &
Me!txtEMail.Value & _
"?Subject=" & Me!txtSubject.Value
Else
Me!lblUnattached.HyperlinkAddress = "Mailto:" & Me!txtEMail.Value
End If
Me!lblUnattached.Caption = "Mailto:" & Me!txtEMail.Value
Else
Me!lblUnattached.HyperlinkAddress = ""
Me!lblUnattached.Caption = ""
End If
Exit Sub
ErrHandler:
MsgBox "Error in txtEMail_AfterUpdate( ) in " & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear
End Sub ' txtEMail_AfterUpdate( )
Private Sub txtSubject_AfterUpdate()
On Error GoTo ErrHandler
If (Nz(Me!txtEMail.Value, "") <> "") Then
If (Nz(Me!txtSubject.Value, "") <> "") Then
Me!lblUnattached.HyperlinkAddress = "Mailto:" &
Me!txtEMail.Value & _
"?Subject=" & Me!txtSubject.Value
Else
Me!lblUnattached.HyperlinkAddress = "Mailto:" & Me!txtEMail.Value
End If
Me!lblUnattached.Caption = "Mailto:" & Me!txtEMail.Value
Else
Me!lblUnattached.HyperlinkAddress = ""
Me!lblUnattached.Caption = ""
End If
Exit Sub
ErrHandler:
MsgBox "Error in txtSubject_AfterUpdate( ) in " & vbCrLf & _
Me.Name & " form." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & Err.Description
Err.Clear
End Sub ' txtSubject_AfterUpdate
' * * * * End code * * * *
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
When you see correct answers to your question posted in Microsoft's Online
Community, please sign in to the Community and mark these posts as "Answers,"
so that all may benefit by filtering on "Answered questions" and quickly
finding the right answers to similar questions. Remember that questions
answered the quickest are often from those who have a history of rewarding
the contributors who have taken the time to answer questions correctly.