1

Our ticketing system has a button you can press that will copy the URL of the ticket you're looking at to your clipboard. But if you paste this into an email, you get the full, very long URL which is really difficult to tease the ticket number out of. Our users like ticket numbers. They don't like long ugly links. So this neat feature doesn't get used much.

I'd like to modify it so that what gets pasted from the clipboard into the email is a hyperlink to the ticket, but one that has a friendly name that is the ticket number. I'm really not sure where to even start. I tried wrapping the URL in an HTML anchor tag, but what gets pasted in Outlook is the full markup rather than a named hyperlink. It doesn't get converted after sending either. What I do know is that if there is already a hyperlink with friendly name on an email, you can copy it to a different email and it will pasted just as you copied it. But if you paste that same link in a text editor, all you get is the friendly name (no URL).

I haven't had much luck searching the web for clues. All the search results are for how to create/copy hyperlinks into Outlook. So either the keywords I need in my search are too generic, or what I'm trying to do is simply not possible. Anyone know whether this is a lost cause?

We're on O365, but most of our users work through the desktop client.

TLDR: Is there a way to format text so that when pasted into Outlook, it will appear as a hyperlink with a friendly name.

1
  • Please edit the question to limit it to a specific problem with enough detail to identify an adequate answer.
    – Community Bot
    May 9, 2022 at 18:56

2 Answers 2

1

Autohotkey can do this with the help of the WinClip class.

Roughly the steps are:

  1. Install Autohotkey, there are portable versions available if you can't install anything on your machine.
  2. Download the WinClip.ahk and WinClipAPI.ahk files and place them somewhere you can find them.
  3. Create an .ahk script with the following contents:
    #Include c:\path\to\WinClipAPI.ahk
    #Include c:\path\to\WinClip.ahk
    
    ; Create a keyboard shortcut for CTRL+ALT+C
    ; Feel free to alter the keys as you desire
    ^!c::
    ; Clear the current clipboard contents
    clipboard := ""
    ; Copy the selected text to clipboard
    Send ^c
    ; Wait until clipboard contains data
    ClipWait
    ; Set the display text. I assume you can derive this from the URL in 
    ; the clipboard by taking a substring from it, but perhaps you need another method
    start := 1 ; position where ticket number starts
    length := 8 ; length of ticket number
    display_text := SubStr(clipboard, start, length)
    full_url := clipboard
    html_path := "<a href=" . full_url . " >" . display_text . "</a>"
    
    ; Set the plaintext and HTML clipboard value
    WinClip.SetText( full_url )  ; this is the plain text value
    WinClip.SetHTML( html_path ) ; this is the HTML formatted value
    
  4. Start Autohotkey with the .ahk script as an argument, e.g.: C:\path\to\Autohotkey.exe C:\path\to\script.ahk
  5. This will start the Autohotkey script in the toolbar. When you now select the URL and press CTRL+ALT+C you will be able to paste a formatted link in Outlook (if it is an HTML e-mail).

The possibly hard part is extracting a ticket number from the URL (you didn't include in your question how it is stored). If it's simply https://www.ticket-system.com/T12345678 you can easily take a substring of the URL by character position as in my example.
However, if it's a more complicated URL with changing parts (e.g. https://ticket-system.com/some-category/T12345678 and https://ticket-system.com/some-category-other/sub-category/T12345678) you need to do some more work in extracting the ticket number you want to display.

4
  • Thanks Saaru, I had previously tried pasting an anchor tag directly into the email, but what was sent was the full HTML markup rather than a hyperlink. This is even with the mail format being set to HTML. After doing a little more reading, it turns out that Outlook has a storied history of not playing well with HTML. It's clear it used to convert anchor tags in the past, but O365 no longer seems to (not even the web client).
    – Mike W
    May 11, 2022 at 16:09
  • I'm not sure how this WinClip sets the HTML clipboard content, but pasting it definitely works in Outlook version 2108 (Build 14326.20910) in an 365 subscription. May 11, 2022 at 16:35
  • Ah, that's interesting! I'll try to see if I can find out the mechanism behind that. Unfortunately, Autohotkey won't work for my scenario as it would need to be deployed and configured for every user within our organization (I actually don't even have enough permissions to install it on my own workstation to test it).
    – Mike W
    May 18, 2022 at 15:00
  • It was not clear from your question that this was for a whole organization, not only for yourself. If it's for the organization you should escalate this to management and indicate that it will save ### k$ in process costs in X years. For the case that you don't have enough permissions to install I've included a link to the portable version in my first point. Portable means that you don't need to install anything and simply can run the executable. In most "locked down" environments running a portable executable is still possible. May 18, 2022 at 15:08
0

Do you want to rename the hypelink in Outlook? If so, here are the steps for your reference:

  1. Right click on the hyperlink you want to rename.

  2. Then click Edit Hyperlink in the right-clicking menu.

    enter image description here

  3. In the Edit Hyperlink dialog box, clear the content in the Text to display box, and then type in the words you want to display. Click the OK button enter image description here

Hope this can help you!

1
  • Hi Faery, thanks for the reply! I guess what I'm trying to do would be akin to copying text from Notepad that when pasted in Outlook would automatically be pasted as a hyperlink with a friendly name. I'm looking for advice on how the text would need to be formatted to make this happen (if it's even possible!).
    – Mike W
    May 10, 2022 at 14:52

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .