# Sending HTML Emails on macOS - Copy from WebViewer

**URL:** https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486
**Category:** Questions
**Tags:** macos, email
**Created:** [September 22, 2021, 2:29pm UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486 "2021-09-22T14:29:31Z")
**Posts on this page:** 18
**Page:** 1

<div class="post-metadata">

### Author: ![xochi](https://avatars.discourse-cdn.com/v4/letter/x/0ea827/32.png) [@xochi](https://the.fmsoup.org/u/xochi)
#### Post date: [September 22, 2021, 2:29pm UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486/1 "2021-09-22T14:29:31Z")

</div>

Due to a long-standing bug in AppleScript and macOS Mail, you can't send HTML format emails: The applescript  
` tell theMessage to set html content to "<html>..."`  
has not worked in recent versions of Mail.app for several years.

I found a clever workaround: if you create a WebViewer and load your HTML content using a "data:text/html..." URL, you can then click to select the WebViewer, and use Edit / Select All. This will copy the HTML to the clipboard, after which you can paste it into a new email message in Mail.app. Works great.

However, I can't seem to find a way to script this inside FileMaker script steps:

```auto
Go To Object "WebViewer1"
Select All
Copy

```

does not work, failing with **Error [3] Command is not availble...**

It is possible to do it using AppleScript and System Events sending the Command-A (Select all) and Command-C (Edit/Copy) keystrokes, but this solution is brittle, and will fail if the user changes the active window.

Question: is there any way to script these steps? (Click to select web viewer, select all, copy) inside FileMaker itself? I'm OK using MBS plugins if that helps.

---

<div class="post-metadata">

### Author: ![OliverBarrett](https://avatars.discourse-cdn.com/v4/letter/o/f19dbf/32.png) [@OliverBarrett](https://the.fmsoup.org/u/OliverBarrett)
#### Post date: [September 22, 2021, 3:13pm UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486/2 "2021-09-22T15:13:53Z")

</div>

Not sure if you would consider this option, but you could also use an email API and connect that to FileMaker via INSERT FROM URL. Then, you could send any email format you want.

---

<div class="post-metadata">

### Author: ![xochi](https://avatars.discourse-cdn.com/v4/letter/x/0ea827/32.png) [@xochi](https://the.fmsoup.org/u/xochi)
#### Post date: [September 22, 2021, 5:17pm UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486/3 "2021-09-22T17:17:15Z")

</div>

Right - in fact that's how I used to do it: I would send emails directly via SMTP (using Curl). Sadly, the organization I'm using went to an extremely strict 2FA system, and refuses to allow either OAuth or app-specific passwords, so the only way I can send emails now is from a mail client.

---

<div class="post-metadata">

### Author: ![OliverBarrett](https://avatars.discourse-cdn.com/v4/letter/o/f19dbf/32.png) [@OliverBarrett](https://the.fmsoup.org/u/OliverBarrett)
#### Post date: [September 22, 2021, 5:29pm UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486/4 "2021-09-22T17:29:59Z")

</div>

I use 2FA with Office 365 email, but with an app password so I guess that wouldn't fly.

Bummer ....

---

<div class="post-metadata">

### Author: ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)
#### Post date: [September 22, 2021, 5:46pm UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486/5 "2021-09-22T17:46:42Z")

</div>

Hi @xochi

I vaguely recall when we lost the ability to set HTML content in a new Mail message via AppleScript.

Feels like around 5-6 years ago. At the time, I maintained a solution that was using that technique. At that time, I did some research and found that it was still possible to script a new Mail message to use rich text content and images. This was not as powerful as using HTML, but it still did allow for setting fonts, font-sizes, colors, and (I believe) basic image insertion.

That solution since left behind the AppleScript/Mail approach, which feels like the right thing, but I still have some code I could share with you if you are interested in playing around with the rich text idea. It never made it into production, so I can't offer any guarantees about having caught and fixed all the gotchas, but I just took a look, and I can see that I tried to make it very simple to integrate. Just tried it with a sample message right now, and it seems to do what is expected.

All that said (and please forgive me if I am preaching to the choir), I think you will be best off when you can leave the AppleScript approach behind.

Kind regards,

-Steve

---

<div class="post-metadata">

### Author: ![xochi](https://avatars.discourse-cdn.com/v4/letter/x/0ea827/32.png) [@xochi](https://the.fmsoup.org/u/xochi)
#### Post date: [September 22, 2021, 7:15pm UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486/6 "2021-09-22T19:15:50Z")

</div>

Steve, does the "rich text" support table styles? The reason I'm using HTML is the need to present a fairly complex table of data.

Another idea would be to save the HTML as PDF, then include the PDF as an attachment to a plain text email. I don't like this solution quite as much, since it often requires the end user to take another action to view the PDF content.

---

<div class="post-metadata">

### Author: ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)
#### Post date: [September 22, 2021, 7:27pm UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486/7 "2021-09-22T19:27:48Z")

</div>

Hi @xochi

No table styles, unfortunately. Just things like font and color (and size) of the text. I don't think that it would be any help at all for rendering a table.

Sorry!

---

<div class="post-metadata">

### Author: ![xochi](https://avatars.discourse-cdn.com/v4/letter/x/0ea827/32.png) [@xochi](https://the.fmsoup.org/u/xochi)
#### Post date: [September 22, 2021, 11:16pm UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486/8 "2021-09-22T23:16:43Z")

</div>

Thanks for the help everyone. This feels like a very 2020s story - something which should be simple is very very difficult due to an overlapping set of bugs and overly restrictive security issues.

- I had a perfectly usable system, sending plain text emails from FileMaker using Curl and a secondary ISP account (basicaly spoofing the "From" address). This worked fine for years.
- A couple of years ago, Mail providers such as GMail started tightening up rules, so spoofed email wouldn't be delivered regularly. (Similar issues happened to mailling lists, due to SPF/DMARC rules).
- So I started sending mail using FileMaker/Curl direct to the proper SMTP server.
- This worked great for a couple of years, but then the agency decided to move to 2FA and blocked external SMTP access.
- I went back to sending plain Text emails from Mail.app using AppleScripting via FileMaker. This worked fine for a while.
- But then I needed to start sending HTML emails (with tables), and I ran into this mysterious applescript / HTML mail bug. And here we are...

/End "Old man yells at cloud" rant.

---

<div class="post-metadata">

### Author: ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)
#### Post date: [September 22, 2021, 11:33pm UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486/9 "2021-09-22T23:33:33Z")

</div>

**Just because I'd like to make sure I am understanding correctly:**

The 2FA still applies when sending the email via Mail.app, but it's just that it's not a blocker in that scenario because there is a human who is actually navigating the 2FA piece when the email is sent via Mail.app ?

---

<div class="post-metadata">

### Author: ![xochi](https://avatars.discourse-cdn.com/v4/letter/x/0ea827/32.png) [@xochi](https://the.fmsoup.org/u/xochi)
#### Post date: [September 23, 2021, 12:16am UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486/10 "2021-09-23T00:16:06Z")

</div>

Good question! The system is an Exchange (Office 365?) server, and used to allow plain SMTP access. During COVID, there was a "big hack" and the agency decided to force everyone into using 2FA with the Duo Authenticator.

My understanding (which may be wrong) is that this uses OAuth under the hood, and Mail.app has support for it, so it all "just works".

After the change, I had to re-enter my password within Mail.app, and at some point it popped open a new window, which looked like a WebKit viewer, which navigated to my agency's site, and (after a few steps) eventually the 2FA was triggered, and I authenticated via my iPhone, and after that point Mail.app worked fine with the Exchange server.

I did some research...

- The common solution for this is to enable "App-specific passwords" so that "dumb" SMTP apps can retain access. Unfortunately, although Exchange and Office 365 supports this, my agency has not enabled this feature.
- There are some FileMaker plugins which claim to support OAuth2 (such as the Mail.it plugin from [Dacons.net](http://Dacons.net)) but it did not seem like this was a viable solution. When I looked into it, the documentation seemed to suggest that to use OAuth2 from a third-party plugin, still required the mail administrators to set up permissions to do so. I would love to be proven wrong on this!

---

<div class="post-metadata">

### Author: ![steve\_ssh](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/steve_ssh/32/160_2.png) [@steve\_ssh](https://the.fmsoup.org/u/steve_ssh)
#### Post date: [September 23, 2021, 12:26am UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486/11 "2021-09-23T00:26:53Z")

</div>

I see -- thank you for that explanation. It makes perfect sense & I appreciate you spelling it out for me.

---

<div class="post-metadata">

### Author: ![Malcolm](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/malcolm/32/196_2.png) [@Malcolm](https://the.fmsoup.org/u/Malcolm)
#### Post date: [September 23, 2021, 12:41am UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486/12 "2021-09-23T00:41:54Z")

</div>

There are ongoing security problems with Exchange Server. The first reports were made public in December 2020. Here we are in September 2021. Last patch tuesday MS released the latest in a series of patches to handle this. Unfortunately, in some cases it prevents anyone on the network from using printers, so the problem hasn't been resolved after 9 months and counting.

---

<div class="post-metadata">

### Author: ![xochi](https://avatars.discourse-cdn.com/v4/letter/x/0ea827/32.png) [@xochi](https://the.fmsoup.org/u/xochi)
#### Post date: [September 4, 2025, 2:49pm UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486/13 "2025-09-04T14:49:22Z")

</div>

To revive an old thread.

After fiddling around a bit with timing by adding some _pause/resume script [0.1]_ steps , the “copy from WebViewer, paste into mail” script, ended up working quite well.

Recently, I came across another method - this uses AppleScript to run a Shell command which converts HTML into Rich Text on the clipboard:

```auto
set theHTML to "<html><body><h1>Heading Level 1 (HTML)</h1><div style='color:blue'><i>this is blue italic text</i></div><body></html>"
set theBody to "Hi There (text)"
set eSender to "test@example.com"
set eSubject to "Testing HTML"
set eName to "Alice Alison"
set eMail to "test@example.com"

my copyHTMLasRTFtoClipboard(theHTML)
set theRTFContent to the clipboard as «class RTF »

tell application "Mail"
	
	##Create the message
	
	set theMessage to make new outgoing message with properties {sender:eSender, subject:eSubject, visible:true}
	
	##Set a recipient and content
	
	tell theMessage
		-- set html content to theHTML ### Note: this is broken in modern macOS versions
		-- set content to theBody ### if you want a plain text email, do this instead
		
		set content to theRTFContent # uses the HTML converted to rich text
		
		make new to recipient with properties {name:eName, address:eMail}
		
		##Send the Message
		## send
	end tell
end tell

on copyHTMLasRTFtoClipboard(pstrHTML)
	-- Takes HTML and converts it to RTF text which is copied to the clipboard
    -- adapted from https://gist.github.com/JMichaelTX/603c98d5f12ffcf5be1b080285982437
	set lstrCMD to "echo " & quoted form of pstrHTML & " | textutil -format html -convert rtf -stdin -stdout | pbcopy -Prefer rtf"
	do shell script lstrCMD
end copyHTMLasRTFtoClipboard

```

---

<div class="post-metadata">

### Author: ![tonywhitelive](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/tonywhitelive/32/208_2.png) [@tonywhitelive](https://the.fmsoup.org/u/tonywhitelive)
#### Post date: [September 4, 2025, 6:14pm UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486/14 "2025-09-04T18:14:48Z")

</div>

I have been using this method for a while…

> **[Create Mac Mail msg with Rich Text content that also has cc: address filled in](https://forum.latenightsw.com/t/create-mac-mail-msg-with-rich-text-content-that-also-has-cc-address-filled-in/2037/4)**
>
> You should include three backticks (\`\`\`) on their own line before and after code. I’ve fixed it for you in the post above.

---

<div class="post-metadata">

### Author: ![xochi](https://avatars.discourse-cdn.com/v4/letter/x/0ea827/32.png) [@xochi](https://the.fmsoup.org/u/xochi)
#### Post date: [September 4, 2025, 6:41pm UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486/15 "2025-09-04T18:41:04Z")

</div>

I notice that your script fails if you have Mail/Composing sent to “Plain Text”, but setting it to “Rich Text” works:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/3/31b5326bedc102a01fafb830ae315dad14adb584.png)

Edit to add: this also may work around a bug with FileMaker’s `Send Mail` script, discussion here:

> **[Claris Community (English)](https://community.claris.com/en/s/question/0D5Vy00001MuH6vKAF/send-email-with-mail-on-macos-badly-formatted-bug?t=1757011337256)**

---

<div class="post-metadata">

### Author: ![MonkeybreadSoftware](https://yyz2.discourse-cdn.com/flex030/user_avatar/the.fmsoup.org/monkeybreadsoftware/32/361_2.png) [@MonkeybreadSoftware](https://the.fmsoup.org/u/MonkeybreadSoftware)
#### Post date: [September 4, 2025, 6:57pm UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486/16 "2025-09-04T18:57:22Z")

</div>

You can use [SharingService](https://www.mbsplugins.eu/component_SharingService.shtml) functions to pass styled text from FileMaker to Mail.

See [SharingService.ShareHTML](https://www.mbsplugins.eu/SharingServiceShareHTML.shtml), [SharingService.ShareItems](https://www.mbsplugins.eu/SharingServiceShareItems.shtml) and [SharingService.ShareValues](https://www.mbsplugins.eu/SharingServiceShareValues.shtml) functions in [MBS FileMaker Plugin](https://www.monkeybreadsoftware.com/filemaker/).

---

<div class="post-metadata">

### Author: ![xochi](https://avatars.discourse-cdn.com/v4/letter/x/0ea827/32.png) [@xochi](https://the.fmsoup.org/u/xochi)
#### Post date: [September 5, 2025, 7:36pm UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486/17 "2025-09-05T19:36:19Z")

</div>

Here’s a small demo FileMaker file which shows the script in action:

[email\_NSSharingServices.fmp12.zip](https://the.fmsoup.org/uploads/short-url/4DnfYBV7xzjtvT5NTp0MZSLmbsa.zip) (127.8 KB)

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/6/6f45a2097228bd0753e6bc785cbba1848fac0c2a.png)

---

<div class="post-metadata">

### Author: ![xochi](https://avatars.discourse-cdn.com/v4/letter/x/0ea827/32.png) [@xochi](https://the.fmsoup.org/u/xochi)
#### Post date: [May 4, 2026, 7:29pm UTC](https://the.fmsoup.org/t/sending-html-emails-on-macos-copy-from-webviewer/2486/18 "2026-05-04T19:29:21Z")

</div>

I just tested the ability to send HTML email from within AppleScript, and it seems to be fixed in the upcoming macOS 26.5:

I had given up on Apple ever fixing this bug, so this is a very pleasant surprise:

 ![image](https://canada1.discourse-cdn.com/flex030/uploads/fmsoup/original/2X/9/9643ff247fc4b1049d91820fce69f677460c1207.jpeg)
