Re: Can I speed up Mail content setting?
Re: Can I speed up Mail content setting?
- Subject: Re: Can I speed up Mail content setting?
- From: Shane Stanley <email@hidden>
- Date: Fri, 29 May 2015 13:16:08 +1000
On 29 May 2015, at 12:33 pm, Brian Christmas <email@hidden> wrote:
I think I’ve managed to add code that will color the main body text a different color foe each report. The color I was sending was for the text, the bullets just use a red.
That looks right, except you should move the beginEditing() line to before it. (Using beginEditing() and endEditing() is optional, but it can speed things up by leaving some of the internal house-keeping until all the changes have been made.)
However, I cannot work out how to address the Emails contents.
I suspect "set newMessage to outgoing message" should be something like "set newMessage to outgoing message 1", and you might need a short delay first to allow the sharing service to finish its business. But... As you can see from the attached code, I need to set the font color and size for different parts of the content, and also add up to three attachments. I’ve given up experimenting, and cannot find anything on the web, so I’m asking, once again, for advice please.
It's pointless doing some of the styling before adding the text and some after -- you should do it all on the attributed string. Doing it in Mail is going to lose you most of the time gains. You have a sample all the code you need -- you just need to change the search strings and the attributes you're adding.
And you can add the attachments by making NSURLs of them, and passing them to performWithItems:. As in:
mailShare's performWithItems:{anNSMutableAttributedString, someNSURL, anotherNSURL [, ...]}
Then all you have to tell Mail directly is to send the message.
The other advantage of doing it this way is that when the next version of Mail comes out and breaks some other part of the scripting implementation, you're immune -- the sharing service stuff is used by so many apps (including Apple apps), the chances of it shipping broken are very slim. |
_______________________________________________
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