tlrichman
tlrichman

Reputation: 33

sending HTML emails in Apple Mail from Safari not working in Yosemite

I'm a graphic designer and spend hours every day designing HTML emails for various clients. The code is built in Dreamweaver and the images are stored on a server. To send tests of these campaigns to myself and my clients I've relied on the following process for at least the last eight years:

  1. Open the HTML file in Safari
  2. Type ⌘I (File > Share > Email This Page)
  3. Mail opens and a new email is created with the HTML file displayed in all it's graphical glory
  4. Select recipient and hit Send 4.

With Yosemite, this process is broken at step 3. Instead, Mail displays a blank email with no content. I've tried getting around this by moving the HTML file to a server, but Mail is overriding some of the HTML, namely the image dimensions specified in the both the <td> and <img> tags.

I've been searching for the past few months for a solution. Anyone else using this same work flow seeing this problem? Or does anyone know of another option for sending HTML emails from Mail?

Using Yosemite 10.10.1, Safari 8.0, Mail 8.1

Upvotes: 2

Views: 8513

Answers (4)

Mauvis Ledford
Mauvis Ledford

Reputation: 42334

I found the only way to successfully do this without breaking responsive layout is to not send through Mail.app but using the open-source Thunderbird.app

Here are my steps:

  1. Copy your html template to your computer's clipboard. It should contain all the head and body HTML tags. (As others mentioned do not use external CSS files, all CSS should be inline already to support all mail provider)
  2. Open Thrunderbird.app (Assume you have already setup your email account you're sending from.)
  3. Create a new blank email (File > new > message)
  4. In top bar: Insert > HTML and then paste in what’s on your clipboard
  5. You may edit any of the content in the email including using the bold, italics, underline tool bar.
  6. If you need to add any HTML, for example add a link to some text, highlight the text, then go to Insert > HTML.

Upvotes: 0

Vuk
Vuk

Reputation: 35

I feel your pain, similar here, had a sweet AppleScript integrated with local Apache server, essentially outward facing DropBox. Users drop files or folders from their local server onto AppleScript, it makes a pretty html with proper links, sends it to Safari, and once rendered it gets created as new HTML email.

Yosemite introduced "markup" tools to Mail attachments, which requires an image kind of file. So what was previously a perfect HTML email, now comes as link to local temp file (useless), or gives an option to convert it to PDF, but links are then all gone, and Mail.app sometimes complains that plug-in is missing.

All in all it feels like an unfinished feature... So Octav is right:

  1. Safari, Select All, COPY
  2. Mail, New Message, Body, PASTE

modified AppleScript, if of any use to anyone:

    -- create html
    set myHTML to "<!DOCTYPE><html><head></head><body>Your HTML here</body></html>"
    --Or in DreamWeaver copy source first
    set myHTML to the clipboard

    -- create a temporary html file
    set tempFile to (path to temporary items folder as text) & "temp.html"
    do shell script "echo " & myHTML & " > " & quoted form of POSIX path of tempFile

    -- open the html file in safari
    tell application "Safari"
        activate
        open file tempFile -- open the html file in safari
        set web_page_is_loaded to false
        repeat until web_page_is_loaded is true
            if (do JavaScript "document.readyState" in document 1) is "complete" then
                set web_page_is_loaded to true
            else
                set web_page_is_loaded to false
                delay 1
            end if
        end repeat

        delay 1 --wait a little longer still, otherwise copy will not work
        tell application "System Events"
            tell process "safari"
                keystroke "a" using command down -- Select all
                delay 0.3 --wait !important
                keystroke "c" using command down -- COPY
                delay 0.3 --wait !important
            end tell
        end tell
    end tell


    --now, onto Mail schenanigans
    tell application "Mail"
        activate
        set newMessage to make new outgoing message with properties {visible:true, subject:"", content:""}

        --this is well dirty, but there doesn't seem to be a better way of selecting message body and giving it a focus
        tell application "System Events"
            tell process "mail"
                keystroke tab   --To
                delay 0.3
                keystroke tab   --Cc
                delay 0.3
                keystroke tab   --Subject
                delay 0.3
                keystroke tab   --From
                delay 0.3
                --add/remove more tabs if you have bcc, priority, etc. fields exposed
                keystroke "v" using command down    -finally PASTE
            end tell
        end tell
    end tell

Upvotes: 1

Chris Bales
Chris Bales

Reputation: 11

I ran into the same problem, and discovered a workaround.

Indeed, you can no longer use "Email This Page" to send a local html file to Mail, when opened as a file, using MacOS 10.10 (Yosemite).

However, if you run a local web server (e.g. Apache) and hit the local html file that way (via its address as served up by Apache), then it does work just fine.

Pain, but doable, and worth it for me.

Upvotes: 1

Octav
Octav

Reputation: 122

After step 1, in Safari hit CMD+A (select all), CMD+C (copy) go to Mail, hit CMD+V (paste)

Upvotes: 1

Related Questions