LC, applescript and mail.app

Mark Schonewille m.schonewille at economy-x-talk.com
Wed Aug 14 09:58:35 EDT 2013


Hi Yves,

This is the short version of the AppleScript I use:

set mailText to "****"
set thisSubject to "Test E-Mail"
set thisEmail to "test at test.xyz"
using terms from application "Mail"
	tell application "Mail"
		set theAccount to "Name of Your Mail Account"
		set theNewMessage to make new outgoing message with properties {account:theAccount, subject:thisSubject, content:mailText, visible:false}
		tell theNewMessage
			make new to recipient at end with properties {address:thisEmail}
			set sender to "Your Name <your at domain.xyzs>"
		end tell
		send theNewMessage
	end tell
end using terms from

and this is a LiveCode script, assuming that the AppleScript is in a field (normally I'd use a property) and the body text is also in a field:

on mouseUp
     put fld "AppleScript" into myAppleScript
     put fld "Body Text" into myBodyText
     replace quote with backslash & quote in myBodyText
     replace cr with backslash & "n" in myBodyText
     replace "****" with myBodyText in myAppleScript
     do myAppleScript as AppleScript
     put the result into rslt
     if rslt is not empty then
          beep
          answer error rslt
     end if
end mouseUp

Careful: if you run this script, it *will* send an e-mail.

--
Best regards,

Mark Schonewille

Economy-x-Talk Consulting and Software Engineering
Homepage: http://economy-x-talk.com
Twitter: http://twitter.com/xtalkprogrammer
KvK: 50277553

Use Color Converter to convert CMYK, RGB, RAL, XYZ, H.Lab and other colour spaces. http://www.color-converter.com

We have time for new software development projects. Contact me for a quote.



On 14 aug 2013, at 10:30, Yves COPPE wrote:

> Hi,
> 
> thanks for the good idea; the text appears without html flags
> but …  as plain text, not formatted, without returns, bold text, …
> 
> no any other idea ?
> 





More information about the use-livecode mailing list