Thursday, March 27, 2014

Creating Embedded Email Links Within Office Documents (Word, Powerpoint, Excel, etc)

We have a new requirement from our users. Basically what they want to do is send a document out to a number of people, have them read it, and then (on the final page) click on a link that will automatically generate an email to a set email address within the company basically saying "I have read and understood this document".

It's actually a pretty simple requirement but something I think is worth documenting just in case it comes up again.

In order to go through this step-by-step I'm going to use Microsoft Word, although you could (in theory) use any Office application.

Let's start with something simple. Open Word;

Microsoft Word: Blank Canvas!
This is basically just a blank word document into which we're going to add the following text;

Here's a simple link;
www.google.co.uk 
Here's a few email tests; 
apellew@gmail.com (blank)
apellew@gmail.com (with a subject)
apellew@gmail.com (with a subject and a body)
As you can see nothing complicated. Paste this into Word (as plain text, just so you don't get any web formatting) and press Ctrl-K and the "Insert hyperlink" dialog box will appear;

Building A Simple URL Link In Word
As you can see the entry box at the top is displaying the text that will appear in the document, while at the bottom you can see the address the link will take you to.

NOTE: If you have any %20 strings (or similar) in the "Address" field then this is because you selected a white space either before or after the URL address. Just click cancel, change the highlighting to not include the spaces, and then try again.

When you return to the document you'll now see the Google address highlighted in blue;
Highlighted Links In Word
Next select the "apellew@gmail.com (blank)" line and again press Ctrl-K. Now when the "Insert Hyperlink" dialog appears click on the "Email address" button at the bottom left;

Inserting an Email Address as a Hyperlink
Here you can enter the details of what you want to display and where you want the email address to go. Just enter "apellew@gmail.com (blank)" in the box at the top, and the email address "apellew@gmail.com" in the email address field. Then click "OK".

Repeat the above process for the second link (with a subject) and enter the subject "THIS IS A TEST".

The final option, an email link with a subject AND a body, is a little more complicated. Word doesn't seem to offer a way of doing this through the "Email address" interface so you'll need to craft the link in direct HTML. The easiest way to do this is to use the same "Existing file or web page" we used to create the first link to Google;

Building a Custom Address To Trigger an Email
Here's the text you need to enter into the "Address" field;

mailto:apellew@gmail.com?subject=TEST WITH A BODY&body=BODY TEXT

This, when clicked on, will create a email with the subject "TEST WITH A BODY" and the email body text of "BODY TEXT". Like this in Outlook;

Email With Subject & Body in Outlook
When you return to your document this will now have all the links highlighted and ready to click. If you export the document to a PDF the links will be maintained.
Post a Comment