Sunday, July 13, 2008

Adding URL's to email messages


I recently received a question from a co-worker about inserting URL's into emails.  Although this isn't a normal topic of this site, I thought others might find it useful as well.

Josh,
I have a quick question. I am interested in how you made this a link. 
I have copied and pasted the info but never been able turn it into a link.
Can you help me?
V/R,
Dana

Absolutely!  Take the red pill and follow me down the rabbit hole...
Outlook will automatically create a link for any valid URL (Uniform Resource
Locator) that you type into an email.  By definition, every URL must start with a protocol.  The most common example of a protocol is seen in your address bar while surfing the Internet: http.  Other examples of protocols include https, mailto, callto and file.
In regards to the last one, let's say you want to create a URL that sends people to:
P:\Information Technology Training Center\Public\SIAC Files\
Keep in mind that the example above is not yet a URL, but it is only a file path.  In order to create a URL from this path, the first thing you need to do is add a protocol at the beginning, like so:
file://P:\Information Technology Training Center\Public\SIAC Files\
Now you can see that the link was created, but it stops after the word "Information".  This is not an error.  This is because of another standard in URL's which states that there can be no spaces in a URL.  There are a couple of ways that we could remove the spaces from this URL:
1. Rename the folders and files from "SIAC Files" to "SIAC_Files", etc.
2. Encode those spaces in our URL into Unicode.
The first option could be a major pain, and probably isn't worth the time, so let's look at the second option.  While it might sound scary at first, encoding spaces into Unicode is very easy.  Simply replace all of the spaces in the URL with %20.  By doing this to our URL, it comes out looking like
this:
And, viola, we have a properly formatted URL!  Outlook, having realized this, has created the link for us.

No comments:

Post a Comment