Best Way to Store and Then Paste a Hyperlink

I have a number of formatted emails that I send out regularly.
All of them contain hyperlinks.
What would be the best way to 'store' them. i.e.. variables or Clipboards (neither of which store hyperlinks to my knowledge- BUT IM SURE IM WRONG =), just not experienced enough.
So yes, the best way to store and then use repeatedly these formatted emails that include hyperlinks.
I am aware of Michael's macro, - looks pretty deep at first glance.

IF that's the only way to do it, then I'll jump into it. BUT if there's an easier solution I'm all ears!

Named Clipboards, just like the System Clipboard, can store the rich-text hyperlink. For each hyperlink, or set of hyperlinks, you could create a Named Clipboard.

Then, with your cursor in the email at the point where you want to insert the links, trigger the KM Macro to paste the links from either the Named Clipboard or KM Variable.

With some extra effort, you could write a Script, or a KM HTML Prompt, that allows you to select one or more links to paste.

If all you want to put in the email is the URL, then you could just store them in a KM Variable.

I manually copied the email from my gmail compose window that had the email with hyperlinks in it.
Copied that and then manually pasted it in a named variable in the Prefs/variables window.
I then made a macro that pastes that clipboard.
no hyperlinks.
is there something I have to do to ‘make’ that variable rich text or Hyperlink capable?

ARG - after posting, saw that I was using variables, but MEANT to be using clipboards, let me try that… my complete bad

Ahem… =), works like a charm. as usual, not focusing. (clipboard)
I appreciate your time and your presence on this forum. VERY helpful.

1 Like

but how do I use %NamedClipboard%z_Hyper_Test% in the send mail action so that it uses the styled text?
When I use %NamedClipboard%z_Hyper_Test% in the body field, it is again, only text, no hyperlinks.

Looks like this KM form does NOT support rich-text, only plain-text.
So you would need to paste it into the actual Apple Mail Send Mail window.

This works for me:

###MACRO:   [MAIL] Paste Named Clipboard into New Mail Message [Example]

~~~ VER: 1.0    2016-11-10 ~~~

[MAIL] Paste Named Clipboard into New Mail Message [Example].kmmacros (4.2 KB)


ADD the Macro TRIGGER of your choice.

Tested using:
Mail 9.3 (3124) on macOS 10.11.4
Keyboard Maestro 7.3.1 (7.3.1)

Example Results

1 Like

yeah, understood, thanx, thats a drag.
I’ve spent days deciding if I am going to move from gmail composition, where my old quickeys were programmed to ‘compose’, OR, If I was going to move toward composing in OS X mail with the beauty of the send mail action.
SO it’s quite a drag that I’m back to the, tab tab tab, or click method to get to the body field, or yes, I understand AppleScript can easily get me there, but I’m back to the old method of ‘locate’ and paste.
oh well, I hope KM continues to support mac mail, and fixes the assignment of the signatures that is currently broken.
It’s all good, great toolset.
Thank you for your time

Hey Troy,

I’ve done a little experimenting with AppleScripting a draft in

It looks to me like your task can be accomplished by:

A) Manually saving a draft email template.

B) Doing some search/replace on the template’s actual .emlx file.

C) Copying the draft template into the Drafts mailbox.

D) Opening it.

E) Sending it.

A bit complicated to set up but doable.

Probably the better option is to create your message on-the-fly with AppleScriptObjC.

# Auth: Christopher Stone (Heavy Lifting by Shane Stanley)
# dCre: 2013/12/04 22:27 +1100
# dMod: 2016/11/16 19:01 -0600
# Appl:
# Task: Create new styled-text email.
# Libs: None
# Osax: None
# Tags: @Applescript, @Script, @ASObjC, @Create, @Styled-@Text, @Email
use framework "Foundation"
use framework "WebKit"
use scripting additions

set theSource to "<html><body><H2>Your Wish is My Command...</H2><br><a href=\"\">Good stuff here</a></body></html>"
set theSource to current application's NSString's stringWithString:theSource
set theData to theSource's dataUsingEncoding:(current application's NSUTF8StringEncoding)
set theStyledText to current application's NSAttributedString's alloc()'s initWithHTML:theData documentAttributes:(missing value)
set mailShare to current application's NSSharingService's sharingServiceNamed:(current application's NSSharingServiceNameComposeEmail)
mailShare's setRecipients:{""}
mailShare's setSubject:"I Wish Styled-Text Emails Could be Scripted in!"
mailShare's performWithItems:{theStyledText}


You can also include attachments, although I’d have to ask Shane how to do it.

Run from an Execute an AppleScript action.



Did you guys figure out a straightforward way to do this? I've got a standard email template I want to send in Mac Mail that includes hyperlinks. Feel like I'm missing something obvious on this.

I used the [MAIL] Paste Named Clipboard into New Mail Message, but the hyperlinks don't carry over.

If you used my macro, [MAIL] Paste Named Clipboard into New Mail Message [Example], then it should work. It works for me.

Are you sure you have a rich-text hyperlink on the KM Named Clipboard?

Thanks for the fast response! Yep, I used your Macro. I just double checked, and in the Named Clipboard I can click on the links within the text portion of the clipboard. There is a slight difference in that I'm not needing a New Mail Message. Rather, this is a message in response to an email I've already received. The Macro I'm executing is "[MAIL] Pase Named Clipboard into New Mail Message". I've removed the first 5 steps (Send Mail Message, Activate Mail, Pause, Down Arrow, Return).

I'm wondering if the "paste" command itself is stripping the hyperlinks. I can click them when they're on the Named Clipboard.

Here is what I have found just now by testing with Keyboard Maestro 9.2 on macOS 10.14.6 (Mojave):

  1. When I paste the rich text hyperlink from the Named Clipboard Switcher Window into a Apple Mail reply message, it appears to paste as a rich text link.
  2. However, clicking on that link does nothing
  3. But if it send the email to myself (different email), when I receive the email the link is hot, and when I click on it it opens the web page.

Got it, thanks! Ended up being a command-v hotkey I'd set up to strip formatting (years ago). All set now. Thanks for looking into this!

1 Like

Hey there JMichael,

I know this is slightly off topic - but I have used this method to copy a snippet of text into a Gmail window (using Google Chrome). When it is straight text it copies and mimics the font properties in the Gmail window. If I add a link it reformats the text and now doesn't match existing text in the email. Is there a way to add links into a Gmail without changing the formatting of the text.


Hey Ryan,

I'm sad to say that @JMichaelTX will not be answering...

The Passing of JMichaelTX

JMichaelTX – Unforgettable Generosity With His Time and Knowledge

It looks like his macro does set the font and size of the link text:

property fontStyleStr : "color:blue; font-family:verdana,geneva,sans-serif; font-size:14px;"

That can be changed, but I don't know if there's a way to make the text and size generic so they match the destination font.