Submit Hint Search The Forums LinksStatsPollsHeadlinesRSS
14,000 hints and counting!

A script to help send HTML email via Mail.app Apps
My friend and I have wanted to find an easy way of sending HTML via Mail.app for a long time. We're confused as to why iChat can reformat links to a short word, but Mail has to show the full string: http://www.apple.com. After much research, she dug up this thread off of the Apple Discussions site, and I thought I'd recap it here for easy access.
  1. In the Finder, go to Applications: AppleScript, and launch Script Editor.
  2. Create a new script, and then copy and paste the contents of this script into the window.

    [UPDATE: This script is now online; sorry for the missing file!]

  3. Save the script in the top-level Library: Scripts: Mail Scripts folder. You can also get to this by going to Applications: Applescript: Example Scripts: Mail Scripts. Call it 'HTML Formatting' (or whatever you want).
  4. Go to Mail.app, open the Script menu (the little icon before help) and select "Update Scripts Menu."
  5. Create a basic HTML page with the content of your mail exactly as it should appear. Upload this to a server you can view from the web.
  6. In Safari (not Mozilla, Firefox, etc.), open the page so it is the frontmost window in your browser (it can be tabbed, as long as it is selected).
  7. In Mail.app, create a new message, with all recipients and the subject set.
  8. Go to the Script menu and select "HTML Formatting" (or whatever you named it).
  9. Click "Front window in Safari," and it will automatically send it for you.
Please note that "Choose File" only works on the immediate network (so far as I can tell). Also, the more people you send to, the longer it will take, so this is NOT useful for mass mailing.

[robg adds: I tested this script, and it does work ... and here are a couple of tips to make it perhaps a bit easier to use. First, you can store the script in your user's Library: Scripts: Mail Scripts folder (just create it if you don't have such a folder). If you store it there, it will appear above the system-provided scripts, and be much easier to find. It also removes the chance that you'll lose your script during a software update that modifies Mail's scripts, for instance.

Also, you don't need to upload the web page if you don't want to send images with the email (i.e. you're just using this method to send true hyperlinks). Instead, just enable the Web Server in the System Preferences Sharing panel, and place the file in your user's Sites folder. You can then load it in your browser, using a URL of the form http://127.0.0.1/~username/file.html, where username is your short username and file.html is the name of the file you saved. You won't be able to send images this way, as the reference to an embedded image will be "127.0.0.1," which of course won't work on the recipient's machine. You could, however, link to images on the web, and those should work (I didn't test that).

Finally, though I understand the evilness of HTML email (though not everyone agrees with me), it is sometimes nice to be able to send true links instead of really long URLs. And as mentioned above, this is *not* a solution you would use to mass mail HTML messages.]
    •    
  • Currently 3.17 / 5
  You rated: 5 / 5 (6 votes cast)
 
[41,382 views]  

A script to help send HTML email via Mail.app | 19 comments | Create New Account
Click here to return to the 'A script to help send HTML email via Mail.app' hint
The following comments are owned by whoever posted them. This site is not responsible for what they say.
A script to help send HTML email via Mail.app
Authored by: jeaginsky on Mar 02, '05 08:33:49AM

there's a 404 on the script link



[ Reply to This | # ]
A script to help send HTML email via Mail.app
Authored by: Mr. X on Mar 02, '05 08:52:47AM

I didn't try this script but I've used another way for quite sometime:

Just install the MailPictures app:

http://www.nikwest.de/Software/

I don't really get what this program is supposed to do, but it has the nice side effect to add a "message is raw HTML" checkbox on each new message window, even with an "import" button to choose a HTML file and everything... Very convenient :)



[ Reply to This | # ]
Use HTML tags directly in Mail messages
Authored by: Viridian on Mar 02, '05 09:32:48AM

Apologies to the submitter, but you don't need to jump through the AppleScript/webpage hoops outlined in this hint. MailPictures is a freeware plug-in that adds a new pane to Mail's Preferences panel, which, among other things, allows you to use HTML tags when you're composing new messages.

http://www.nikwest.de/Software/

Read about its primary features on the website. The feature I find most useful is the fact that under MailPictures "Advanced" tab, there is a checkbox marked "Show options in compose window". This puts three new buttons in compose windows, the most interesting of which (to me) is the third, marked "Message is raw HTML". Check this box when you're writing a new message, and you can simply format it with HTML tags. You can view the message-in-progress by saving it to Drafts and looking at it there. Just don't close the window with the source, or you won't be able to edit it any further. Works like a charm.



[ Reply to This | # ]
Use HTML tags directly in Mail messages
Authored by: shurakai on Mar 02, '05 12:37:54PM

Great! I'll try that out! The point of this submission was mainly to inform, and if there's a better way out there: it was too hard to find for 2 people and several years of on-and-off searching: maybe I should have tried a different search string :)



[ Reply to This | # ]
A script to help send HTML email via Mail.app
Authored by: vdubya on Mar 02, '05 10:16:13AM

You can also try Mailings. It's not free, but in a quick test it does what it says. I just built a page and placed it on my host computer, then Mailings does the rest.

http://www.limit-point.com



[ Reply to This | # ]
A script to help send HTML email via Mail.app
Authored by: leenoble_uk on Mar 02, '05 12:10:05PM

HTML email wouldn't be so bad if there was an easier way to provide a plain text alternative.
I just tried out the MailPictures plugin and yes it does do HTML but it doesn't send any plain text alternative.

In the past when I've wanted to send an HTML email I either have to use my own PHP script and run it off my server or use a bulk mailing application. I recommend DirectMail. Just paste in your HTML and your plain text and click send. Does what it says on the tin. You don't have to use it for spamming people.

---
So, I said ... well, I can't actually remember exactly what I said. But it was one of the most enormously cruel and frighteningly witty put downs ever.

[ Reply to This | # ]

Netscape 4.7 could do it...
Authored by: hamarkus on Mar 02, '05 02:08:27PM

Not a really convenient solution, but it works:

In Netscape 4.7 (under Classic) one can choose 'Insert Link' when composing a message. Upon sending one is asked whether one wants to send a HTML-only, text-only or both HTML and text e-mail.



[ Reply to This | # ]
Newsletter 2.1 Can as well
Authored by: kevinneal on Mar 02, '05 03:20:25PM
A free app called Newsletter also lets you sent HTML and Plain text alternative emails

[ Reply to This | # ]
Direct Mail Wipes out New Windows in Finder
Authored by: peterrosen on Mar 02, '05 10:02:57PM

I download Direct Mail and was going to drag and drop an image onto its interface from the finder. Command N failed to open a new window in the Finder. Now Finder doesn't respond to command N, even after quitting DM???

I must restart and quit all my open programs, what a pain... is anyone else having a problem? I am in 10.3.8 on AL 1.25 powerbook with 748K Ram.

I was reading about MAIL.APP in MacINtouch not opening windows when replying to a message. Do you think reading that has caused my Finder to fail? BTW, I have also experienced the same Mail.app issue: http://www.macintouch.com/mail.app11.html#mar02.

Can someone help me find my finder windows?

LOL :-(



[ Reply to This | # ]
A script to help send HTML email via Mail.app
Authored by: lewsmind on Mar 02, '05 02:10:07PM

Like the original poster I also have been searching for this for a long time. All the options laid out above have been really helpful. thanks to everyone.



[ Reply to This | # ]
A script to help send HTML email via Mail.app
Authored by: DavidRavenMoon on Mar 02, '05 07:46:01PM

Even though I prefer Mail, I started using Entourage because I like to be able to put a picture in my email, rather then as an attachment.

Some of my in-laws use PCs (or AOL) and where having problems when I attached pictures... they didn't get them inline, and it seems either they can't find the attachment, or they didn't get it. I have Entourage set up for plain text unless I click on the HTML button, so I don't always have to send HTML formatted mail.

Personally I like it better than plain text.

I'll have to try some of these methods! :)

---
G4/466, 1 GB, Mac OS X 10.3.8



[ Reply to This | # ]
A script to help send HTML email via Mail.app
Authored by: r13 on Mar 02, '05 10:02:29PM

For those who doesn't know, you can just copy HTML texts (with links) and paste it in Mail. It will show exactly the "short" word links as the original, and not the full url. Try it! :)

It can work with pictures too! I had tried copying an article (with pictures) online, pasting it in Mail and email to my friends as a HTML email.



[ Reply to This | # ]
A script to help send HTML email via Mail.app
Authored by: r13 on Mar 02, '05 10:26:22PM

Sorry, just checked with my friends, and the links are broken... You get the visual, but not the links... :(



[ Reply to This | # ]
A script to help send HTML email via Mail.app
Authored by: bluehz on Mar 08, '05 12:14:37PM
Here's a quick script I whippped up for sending html+plain text email from terminal. I believe it does require a working sendmail/postfix. Anyway - thought I would post for others, it could of course be vastly improved.
#!/bin/sh

#
# USER DEFINED VARIABLES
#

name="Your name here"                 # real name
fromaddr="name@server.com ($name)"  # e-mail address  
replyaddr="name@server.com ($name)"         # reply to e-mail address

# var
boundary=`openssl rand -base64 12`

#
# MAIN
#

# Usage

if [ $# -lt 3 ] ; then
  echo <<EOF "Usage: $(basename $0) subject address plaintxt htmltxt

   Where plaintxt points to a plain text file
   and htmltxt points to an html formatted file"
EOF
  exit 1
fi

# Send email

( echo "From: $fromaddr"
  echo "Subject: $1"
  echo "To: $2"
  echo "Reply-To: $replyaddr"
  echo "Return-Path: $fromaddr"
  echo "MIME-Version: 1.0"
  echo "Content-Type: multipart/alternative; boundary=$boundary"
  # add as many X-Headers as you desire below
  echo "X-Priority: 3"
  echo "X-Mailer: MailX"
  echo "X-System: Mac OS X"
  echo ""

# Plain Text Content
echo <<EOF "This is a multi-part message in MIME format.
If you see this message, then you are not using a
MIME compliant mail reader.

--$boundary
Content-Type: text/plain;
	charset=\"US-ASCII\"
Content-Transfer-Encoding: 7bit"
EOF
if [ $4 ]; then
cat $3
fi
echo ""

# HTML Text Content
echo <<EOF "--$boundary
Content-Type: text/html;
	charset=\"US-ASCII\"
Content-Transfer-Encoding: quoted-printable"
EOF
if [ $4 ]; then
cat $4
else
cat $3
fi

echo ""
echo "--$boundary--"
  
) | sendmail -t

exit 0


[ Reply to This | # ]
A script to help send HTML email via Mail.app
Authored by: cfcek2 on Jul 13, '05 06:03:20PM

Am I the only one who doesn't understand where to click "front page in Safari." I don't see it, can't find it ... what am I missing?

Thanks!



[ Reply to This | # ]
A script to help send HTML email via Mail.app
Authored by: timgaden on Sep 17, '05 08:52:57PM
Perhaps an easier way to get around the long URLs problem is to use something like TinyURL (using a method like this).

Doesn't help at all with images or other things that you might like to send via HTML formatted emails, of course, but I've found it the best work-around for email clients unable to cope with Apple Mail's "delsp=yes" setting.

[ Reply to This | # ]
TinyURL
Authored by: sjk on Sep 17, '05 11:57:59PM

I've never trusted TinyURL links because they masquerade the true URL, making them a potential security risk, although I see they've added a preview feature for them -- cool!



[ Reply to This | # ]
Thunderbird
Authored by: bjoossen on Feb 19, '06 03:03:39PM

I've tried all the hints reported here (AppleScript, MailPictures, shell script) and it never worked for me.
Finally, I've downloaded Thunderbird from mozilla.org and as it supports natively HTML email composing, it's easy and works great.



[ Reply to This | # ]
Thunderbird
Authored by: Mloader on Jul 01, '09 09:54:03AM

I was making this harder than it needs to be. Not sure when this popped up but in Safari 4, just do command + I.



[ Reply to This | # ]