• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Yosemite Mail — New Message from Template
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Yosemite Mail — New Message from Template


  • Subject: Yosemite Mail — New Message from Template
  • From: Christopher Stone <email@hidden>
  • Date: Wed, 12 Aug 2015 18:39:22 -0500

Hey Folks,

As far as I know this did not work pre-Yosemite.

This script will create a new DRAFT styled-text (HTML) message.

You used to have to send it immediately to get it to work — or so it was thought — would someone still using Mavericks test this script for me?

I noticed today using Mail on 10.10.4 that I could save, close, and reopen it and retain the formatting.

Unfortunately I can't figure out a way to reopen it for editing via normal AppleScript.

I think I'll have to resort to Keyboard Maestro or System Events to do that.

So it's still kludgey, but it's doable.

--
Best Regards,
Chris

-------------------------------------------------------------------------------------------
# Auth: Mark Munro (Macscripter)
# Mods: by Christopher Stone <email@hidden>
# dCre: 2013/08/04 01:09
# dMod: 2015/08/12 18:25
# Appl: Mail
# Task: Make new HTML email!
# Tags: @Applescript, @Script, @Mail, @New, @Message, @HTML, @Content
-------------------------------------------------------------------------------------------

set toName to "Addressee Name"
set toAddress to "email@hidden"
set textSubject to "HTML Test"

set textBody to "<HTML>
<BODY bgcolor=\"#99CCFF\">
   <H1>Hi There</H1>
   <p>This is very minimal <u>\"hello world\"</u> HTML document.</p> 
</BODY>
</HTML>"

mailMessageCreate(toName, toAddress, textSubject, textBody)

-------------------------------------------------------------------------------------------
--» HANDLERS
-------------------------------------------------------------------------------------------

on mailMessageCreate(toName, toAddress, textSubject, textBody)
  tell application "Mail"
    activate
    set refMessage to make new outgoing message with properties {subject:textSubject, visible:false} -- visible MUST be false to work
    tell refMessage
      set html content to textBody -- must set the _HTML CONTENT_ rather than the _CONTENT_
      make new to recipient at end of to recipients with properties {name:toName, address:toAddress}
      save
    end tell
    close front window
  end tell
end mailMessageCreate

-------------------------------------------------------------------------------------------

 _______________________________________________
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

  • Follow-Ups:
    • Re: Yosemite Mail — New Message from Template
      • From: Shane Stanley <email@hidden>
  • Prev by Date: Re: Script Utilizing an Alternate Printer
  • Next by Date: Re: Yosemite Mail — New Message from Template
  • Previous by thread: Re: Script Utilizing an Alternate Printer
  • Next by thread: Re: Yosemite Mail — New Message from Template
  • Index(es):
    • Date
    • Thread