Heo,
I’m new to the forum, but I have already learned a lot by reading…
I had a script (which I use in FieMaker) to read a rtf document and past it to the body of an email message.n The script used ‘System Events’ ant the keystroke. But, the disadvantage of this script is that, if you press on a key during the running of the script, it fails… and since the script should be used by other persons…
After looking around, I houd Cocoa and nog I have this script, which runs perfectly in Scripteditor:
[AppleScript]
on run – needs to run on main thread
if current application’s NSThread’s isMainThread() as boolean then
doStuff()
else
my performSelectorOnMainThread:“doStuff” withObject:(missing value) waitUntilDone:true
end if
end run
on doStuff()
set theFile to ((path to desktop folder as text) & “textB.rtf”)
set theattachement to POSIX path of ((path to desktop folder as text) & “File.pdf”)
set fileData to current application’s NSData’s dataWithContentsOfFile:(POSIX path of theFile)
set {attrstring, attributes} to current application’s NSAttributedString’s alloc()'s initWithRTF:fileData documentAttributes:(reference)
if attrstring is missing value then error “Unable to read RTF file”
tell (current application’s NSSharingService’s sharingServiceNamed:“com.apple.share.Mail.compose”)
set its subject to “This is a test subject”
set its recipients to {“first@someISP.com”, “second@anotherISP.net”
set bijlage to current application’s NSURL’s fileURLWithPath:theattachement
its performWithItems:{attrstring, bijlage}
end tell
end doStuff
[/AppleScript]
Now, I want have to questions:
- I want to add a sender to the mail, since I have mute accounts
- I want to replace some words in the rtf file
Can someone help me to adjust the script???
When I search on the internet, the syntax of the scripts of Cocoa is different, so I don’t know how to do it.