scripting mail for visual impact
scripting mail for visual impact
- Subject: scripting mail for visual impact
- From: Adam Morris <email@hidden>
- Date: Sat, 28 Mar 2009 02:44:53 +0900
This is a good problem to solve.
On a whim I tried the following work-around. The idea I had was using
an existing rtf file, copying the contents of that file, then putting
it into the contents of a new outgoing message in Mail:
property desktopFolder : path to desktop folder as text
tell application "Mail"
set fileRef to open for access (desktopFolder & "mock-up.rtf")
set marketingContent to read fileRef
close access fileRef
make new outgoing message with properties {content:marketingContent,
visible:true}
end tell
No luck, because it'll just copy the rtf info as literal text.
Then I tried this, which takes a saved messages in the drafts folder
and forwards it to someone in the list:
tell application "Mail"
activate
set oldPref to default message format
set oldPref2 to quote original message
set default message format to rich text
set quote original message to false
-- You have to set up a template draft message first
set allofthem to every message of drafts mailbox
set foundIt to {}
repeat with thisone in allofthem
if subject of thisone is "hi there subject" then
set foundIt to thisone
exit repeat
end if
end repeat
if foundIt is not {} then
set everyAddress to {{"Adam", "email@hidden"}} --
database goes here or set as property
repeat with thisAddress in everyAddress -- supplied from database
set outEmail to forward (item 1 of foundIt) with opening window
tell outEmail
set visible to true -- so you can see it happening
make new to recipient with properties {name:item 1 of thisAddress,
address:item 2 of thisAddress}
end tell
end repeat
else
display dialog "Didn't work, can't find marketing message."
end if
set default message format to oldPref
set quote original message to oldPref2
end tell
This isn't desirable either because you still don't get the pictures.
(And I get an error.)
Then it came to me. Just use Pages! It has a share feature that you
can script easily! The downside of that though is that it'll send it
as a PDF attachment, which isn't the same as the default content.
Seems to me you need to look at a solution other than using Mail.
There are plenty of command-line solutions that use MIME that would
probably take a binary HTML as the content, but then you have the
dreaded passing binary at the command line issue.
There must be a way to do this, but I really don't think scripting
Mail is the way. It doesn't seem to have the features to do even a
work-around.
I need to have a styled email with some images
embedded, so putting a message into my script doesn't work. The idea
is to have the message written and saved in Mail, then have
AppleScript open it, then address and send it without eliminating the
original Draft.
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden