2 Replies Latest reply: Jan 24, 2011 12:51 PM by Jacki
Jacki Level 2 Level 2 (225 points)
Hi - I've been using a script to send mailouts from a filemaker database to our clients where it creates a new message individually for each address and sends through Entourage. However, Entourage doesn't support html and my client is wanting to send html messages with formatting like web pages - so I've been trying to figure out how to do this either in Thunderbird or Mail... Using the same script I've been using but changing the application name to Thunderbird or Mail (and the folder to Drafts instead of Outbox) is giving an error and I'm not sure where to go from here! Would SO appreciate any help or suggestions as to another way to do this! Thanks!

Here's the script that works with Entourage:

tell application "FileMaker Pro"
open "Macintosh HD:Users:jacki:Documents:Judith:Mailing List - Judith.fp7"
set record_count to count records of document "Mailing List - Judith.fp7"
repeat with i from 1 to record_count
go to record i
set message_to to cellValue of cell "EMAIL" of record i
tell application "Microsoft Entourage"
set message_source to source of message -1 of folder "Outbox"
make new outgoing message at the outbox folder with properties ¬
{time sent:current date, source:message_source, recipient:message_to, account:POP account 3}
end tell
end repeat
display dialog "Messages Sent: " & i
end tell

Mac Pro 8-Core Desktop, Mac OS X (10.6.6)
  • hubionmac Level 2 Level 2 (435 points)
    Hi there!
    When I first read your posting I searched google and found a posting saying "You would have to buy a plug-in to send html-emails..."

    But then I thought about a perl script called sendEmail which can be downloaded here.
    This tool allows you to send Emails a shell prompt and this can be an html-email, too.
    The real trick about HTML-Newsletters is to send both, HTML and plain text so that everyone can read your newsletter (readable to both types of email clients: those accepting html and those who don't).
    After some more research I found an very usefull articel here which explains how such muti-part-emails have to look like.
    Ok you can read this article to understand how the native source of an email looks like...
    A very simple way to get the strukture of such an email is to send a formatted email (e.g. type some text and make it bold) via Apple Mail to yourself.
    Then take a closer look at the email's source (pressing cmdoptionu within your message viewer)...

    From: Hubi Schulze <from@domain.comgt;
    Content-Type: multipart/alternative;
    boundary=Apple-Mail-2--315609391
    Subject: TestMail
    X-Universally-Unique-Identifier: d6dfd430-0696-4fe5-9997-1060d2ae26b3
    Date: Sun, 23 Jan 2011 22:46:10 +0100
    Message-Id: <C887B8EB-E79A-40CA-8919-D32FCB41FF06@hubionmac.com>
    To: to@domain.com
    Mime-Version: 1.0 (Apple Message framework v1082)
    --Apple-Mail-2--315609391
    Content-Transfer-Encoding: 7bit
    Content-Type: text/plain;
    charset=us-ascii

    This is your text

    --Apple-Mail-2--315609391
    Content-Transfer-Encoding: 7bit
    Content-Type: text/html;
    charset=us-ascii

    <html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><b>This is your text</b></body></html>
    --Apple-Mail-2--315609391--



    after cleaning some lines I ended up with this:

    From: Hubi Schulze <from@domain.com>
    Content-Type: multipart/alternative;
    boundary=SendEmail-2--315609391
    Subject: TestMail 222
    Date: Sun, 23 Jan 2011 22:46:10 +0100
    To: to@domain.com
    Mime-Version: 1.0

    --SendEmail-2--315609391
    Content-Transfer-Encoding: 8bit
    Content-Type: text/plain;
    charset=UTF-8

    This is your text
    --SendEmail-2--315609391
    Content-Transfer-Encoding: 8bit
    Content-Type: text/html;
    charset=UTF-8

    <html><head></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><b>This is your text</b></body></html>
    --SendEmail-2--315609391--



    This is the raw source of an Email sent by from@domain.com to to@domain.com...

    Save this as a simple text file (mymail.txt at your desktop) and now run the sendEmail (let's say you stored in at your desktop, too)
    Example shows sending through a gmail account:

    ~/Desktop/sendEmail -f from@domain.com -t to@domain.com -s smtp.gmail.com:25 -xu gmailusername -xp gmailpassword -o tls=auto -o message-format=raw -o message-file=~/Desktop/mymail.txt



    That's it.. you get an html/text Email via SendEmail =)

    So all you have to do is build such a file via AppleScript/Filemaker and send it using sendEmail...

    Finally I would suggest using a newsletter service, because they have the infrastructure so send thousands of emails
  • Jacki Level 2 Level 2 (225 points)
    Thanks SO much for the info - I think I can figure this out and make it work...!

    The reason we've held off on going with the newsletter services is because we only have a little over 1,000 people in our database and it seems too expensive to go that route - unless they have free/inexpensive ones available...!

    Thanks again!