I need to get formatted text into Mail. I have a way to do this involving three steps.
- Create the text in a text edit document (or load a previously formatted document)
- Copy the text to the clipbaord
- Paste into a mail message.
This works but ultimately i would like to only get the text after a certain point in the text document. In this case starting with paragraph 6. The first five paragraphs are the details of who to send the mail to and what the subject is.
Question 1: Is there a way to select a range of text in text edit?
Alternatively, has anyone managed to format the text (Bold, underline, italic) of a message?
I have search on both of these and have not found any answers.
Thanks
Dee
Model: MacBook Pro 17
AppleScript: XCode 2.4.1
Browser: Safari 419.3
Operating System: Mac OS X (10.4)
Hi,
First I have to say I don’t know much about inserting formatted text into mail. I do have a script that will read a text file and put that in a message of a new e-mail. Hopefully a piece or two of this will work for you. I modified a part of it to omit the first five paragraphs of text of the text document.
set thefile to (choose file) as Unicode text
set mytext to readfromfile(thefile) as text
set theMessage to paragraphs 6 through -1 of mytext as text
set thesubject to "Here's my text"
set theAddress to "anon@anon.com"
makeEmail(theAddress, thesubject, theMessage)
on readfromfile(thefile)
set fRef to (open for access file thefile with write permission)
close access fRef
set mytext to read file thefile as text
return mytext
end readfromfile
on makeEmail(theAddress, thesubject, theMessage)
tell application "Mail"
set thesubject to "PDF proofs"
set newMessage to make new outgoing message with properties {subject:thesubject}
tell newMessage
set visible to true
make new to recipient at end of to recipients with properties {address:theAddress}
set content to theMessage
end tell
end tell
end makeEmail
Let me know if this helps you along…
Joe
Dee,
here’s how to copy paragraph 6 of TextEdit to a new Mail msg. (will only work with one style - handling multilple styles in the paragraph would be more complicated …)
tell application "TextEdit"
tell document 1
set par_props to (properties of it's paragraph 6)
set par_text to it's (paragraph 6)
end tell
end tell
tell application "Mail"
set thesubject to "subject"
set newMessage to make new outgoing message with properties {subject:thesubject, visible:true, content:par_text}
tell newMessage
make new to recipient at end of to recipients with properties {address:"test@test.xy"}
set properties of it's content to {size:size of par_props, color:color of par_props, font:font of par_props}
end tell
end tell
D.