start Outlook - new mail and paste e-mail address to the mail

F

Flemming

Hi,

I need some help. On double click I need to copy the e-mail address,
open Outlook, start a new mail and paste the e-mail address into the
to field.

Appreciate any help. Thank you.

Flemminh
 
6

'69 Camaro

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.
 
O

Ofer

You can use the SendObject , the true in the end indicate that you want to
open outlook, the false mean to send mail without openning outlook, True is
the default.


docmd.SendObject acSendNoObject,,,me.AddressFieldName,,,"Subject","Message
Text",True
 
6

'69 Camaro

Hi, Ofer.

FYI, SendObject( ) is buggy, particularly if it's in a loop and more than
one E-mail message is generated. We don't recommend it any more.

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.)
 
O

Ofer

Gunny, thanks for the tip.


'69 Camaro said:
Hi, Ofer.

FYI, SendObject( ) is buggy, particularly if it's in a loop and more than
one E-mail message is generated. We don't recommend it any more.

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.)
 
F

Flemming

Thank you very much.

"'69 Camaro" skrev:
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.
 
F

Flemming

Hi,

I got error 438. Object does not support this property or method?

Any suggestions?

Thank you

"'69 Camaro" skrev:
 
6

'69 Camaro

Hi.

The code below is intended for an unattached label. Are you using an
unattached label for this? (Only a few types of controls can even hold a
Hyperlink object.) If you are, then what version of Access are you using?

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.)
 
F

Flemming

No. Same error message. I tried Ofer's suggestion and that
opens Outlook new mail and incert the e-mail address.

But any ideas?

Thank you

"'69 Camaro" skrev:
 
6

'69 Camaro

Hi.

If you are going to use a label for this, then you must use an unattached
label, not an attached label. (Select the Toolbox CommandBar "Label" button
and drag it to your form for an unattached label.)

Check the Properties dialog window for this unattached label. Select the
"Format" tab. Do you see the Hyperlink Address and Hyperlink SubAddress
Properties listed under the Caption Property? (They should be blank, but
they should exist.) If you don't see these two properties listed, then you
are not using an unattached label, but an attached label, which cannot hold
a Hyperlink object.

Alternatively, check the Parent Property of the unattached label. If the
parent is the form, then it's an unattached label. If the parent is a
control on the form, then it's an attached label.

If you are indeed using an unattached label, then please post your code and
indicate the line that is highlighted in your debugger window when the error
occurs.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.
 
F

Flemming

Hi,

Thx. for your effort to assist me. When I create a Label using the toolbox
the I see what you ask for but I do not see txtEMail_AfterUpdate()
in the Labels properties.

Do you mean that I sould create a txtbox and rename the label?

Best,
Flemming

"'69 Camaro" skrev:
 
6

'69 Camaro

Hi.
When I create a Label using the toolbox
the I see what you ask for but I do not see txtEMail_AfterUpdate()
in the Labels properties.

This AfterUpdate( ) event is for the text box that holds the E-mail address,
not for the unattached label. You didn't mention what your controls were
named, so I made up an example for you to adapt your form to. The example
code requires three controls: the unattached label (named lblUnattached in
the example) for the hyperlink, the bound text box for the E-mail address
(named txtEMail in the example), and the bound text box for the subject
(named txtSubject in the example).

You'll need to replace these example controls' names with the names of these
controls on your form after you paste the example code into the form's code
module. Save the module and compile the code. Then, ensure that your
E-mail address text box has the OnAfterUpdate( ) event selected in its event
properties so that this code will execute when this event is triggered.
Also ensure that the Subject text box has the OnAfterUpdate( ) event
selected in its event properties so that this code will also execute when
this event is triggered.

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.)
 
S

Stephanie

Hi, Gunny. Hope you're still tracking replies.
I am using a Phone List form (sort of like a rolodex that shows name,
address, phone, and email). When I click on email, I'd like Outlook to start
a new email with the To field populated by the email that I clicked on in the
Phone List form, but with a blank Subject line on the email.

I've followed your steps: I created a "fake" txtSubject (I made it not
visible and there's nothing in it)- maybe that's my problem...But I don't
want a the Outlook email to have a populated subject line.

I have txtEmail that contains my Email address (Control Source is my
EmailName). I created a lblUnattached that is hyperlink-ready.

When I'm in my form and click on Email, nothing happens. First, should this
field "look" different (hyperlink fields are generally have blue font- do I
need to do that manually?). Second, I'm not kicking off Outlook.

I'd appreciate your guidance. Thanks.
 
T

tcorlew

I am new to making codes so I am not familiar as to exactly what I need to do.

This is my Table

Table name:
SalesPersons

Fields:
SalespersonsName----Primary key
Phone
Ext
Fax
Email
Cell
Notes

I want it to bring up outlook express which is my hyperlink C:\1386

I don't care anything about having the subject line filled. All I want to
do is when I bring up a salesperson I just want to be able to click on their
email address or a command button that will bring me into a new email. I
want to eliminate copying and pasting.

Also, since I have never done this before and if it is no trouble I need
dummy explanations. Like, do i click on the unattached label and where it
says hyperlink address insert C:\1386, do I need to put anything in hyperlink
subaddress? What do I name the unattached label? Those kind of
things.....really stupid here.

Thanks,
Tina
 
T

tcorlew

Thanks for the help. This worked as far as bringing up the email box but it
didn't populate the email with the address.

This is how I have it set up.

The field name is Email from my Vendors table.

I am guessing that when i go to properties.

On Click....I go to build Macro
Then select send object

For the bottom part I have this:

Object Type: ______________________
Object Name: Vendors!Email
Output Format: ______________________
To ______________________
CC ______________________
Bcc ______________________
Subject ______________________
Message Text ______________________
Edit Message ______________________
Template File ______________________

I don't know if I should field out anything else. Or that what I do have
field out is incorrect. Any ideas??





Then I select SendObject
 
S

Stephanie

I skipped all of the code that was previously posted. It seems to be for a
different scenario.

Here's what I've done:
on your field Email, go to properties (like you've done) for the On Click
event, but rather than choosing macro builder, choose Code Builder. A Visual
Basic screen opens with a preset:

Private Sub EMail_Click()

End Sub

In between, insert:
DoCmd.SendObject acSendNoObject, , , EMail

Copy and paste this in so your code looks like:

Private Sub txtEMail_Click()
'line that would open Outlook to a new message with the To box populated
DoCmd.SendObject acSendNoObject, , , EMail
End Sub

Then close the Visual Basic window.
I also change the font color of the Email field to blue so that it looks
like a hyperlink.

Hope that works for you!
 
Top