Link to home
Create AccountLog in
Avatar of SteveL13
SteveL13Flag for United States of America

asked on

Click hyperlink field on a form and have it open an Outlook email window to that email address

On a form I have a field that is an email field.  I have it set as hyperlink on the form.

When the user clicks the hyperlink I want it to open an Outlook email window to that email address.

What is the onclick code to do that?
Avatar of Paul MacDonald
Paul MacDonald
Flag of United States of America image

You can't force Outlook to open, but a mailto: tag will open the user's default mail application if one is set up.
Avatar of SteveL13

ASKER

Outlook will be open already.  What is the onclick code to make Outlook have the email address in the To: field
It's in the link I posted.

mailto:someone@example.com?Subject=Hello%20again
Do not use the hyperlink data type.  Change it to a standard text field.  In the click event (or preferably the double-click event) use the FollowHyperLink method.  This command recognizes any valid file extension, url, or email address and opens the appropriate application.

On the form, the Hyperlink property simply specifies how the control will be displayed.  It doesn't do anything else.  You must add your own code to open the document.

I suggested the double-click event because even though you want it to act like a hyperlink, if you use the single click, you won't be able to actually edit the value easily because trying to click into the control will cause the hyperlink to be activated.  If you can train your users to always use the tab key to move from control to control, you would be able to get focus into the control and start typing but you still could never click into the center to change a couple of characters.
I'll use double-click but I don't know how to code it.
ASKER CERTIFIED SOLUTION
Avatar of PatHartman
PatHartman
Flag of United States of America image

Link to home
membership
Create an account to see this answer
Signing up is free. No credit card required.
Create Account
Doesn't want to work.  I do not have the field set as a hyperlink but when I double-click the email address I get:

User generated image
And then when I click "Yes" I get:

User generated image
The value is incorrect.  It needs to be either what is to the left of the # or what is to the right.  The security message is caused by your macro settings.
I found the mistake in the table field value.  Once I fixed it all is fine.  Thanks.