Is it possible to applescript the saving of a message to RTF in Mail.app?

I'm fiddling with a script that takes selected messages in Mail.app and, among other things, saves the messages as RTF files. The "Save As..." option in the File menu has the ability to save as the RTF type, but I can't seem to get this done in applescript with the "save" command. I've tried passing it a window object from the message viewer, but it just barfs. Does anyone know if Mail.app can be scripted to save a message to an RTF file (with a file name/path supplied via the AS program)?
Thanks in advance for your help.
P.S. I've tried circumventing this problem by trying to assemble a text document from the email message parts (subject, sender, contents, etc.) using TextEdit, with no success with formatting, but I'd rather get Mail to do it because it already formats the saved email nicely if you do it interactively in the "Save As..." dialog.

Just to make my question a little less abstract, here is the script as it stands so far:
(* START SCRIPT *)
tell application "Mail"
activate
set selectedMessages to the selected messages of front message viewer
set saveFolder to choose folder with prompt "Please pick an empty folder for me to store the email information:"
tell application "Finder"
set parentFolder to folder saveFolder
set parentFolderPath to parentFolder as Unicode text
end tell
repeat with aMessage in selectedMessages
properties of aMessage
set messageSender to sender of aMessage
set messageSubject to subject of aMessage
set messageSent to date sent of aMessage as string
set messageContent to content of aMessage
if (messageSender is "[email protected]") and (messageSubject begins with "manuscript #") then
-- Get thingie number from message subject after '#'
set oldDelimiter to my SwitchDelimiterTo({"#"})
set manuscriptNumber to last text item of messageSubject
my SwitchDelimiterTo(oldDelimiter)
log "NOTE: Email for manuscript #" & manuscriptNumber
-- Make the folder in which to store the stuff for this manuscript;
-- variable "manuscriptFolder" will point to place to store files
tell application "Finder"
try --ignore problems with folder creation, like existing folders/files
set manuscriptFolder to make new folder in parentFolder with properties {name:manuscriptNumber}
on error errorName number errorNumber
if errorNumber is -48 then -- Folder already exists
log "NOTE: folder " & parentFolderPath & manuscriptNumber & " already exists."
set manuscriptFolder to folder manuscriptNumber in parentFolder
end if
end try
end tell
set manuscriptFolderPath to manuscriptFolder as Unicode text
set messageFileName to manuscriptFolderPath & "email.rtf"
log "NOTE: Saving manuscript to file: " & messageFileName
-- Use TextEdit to construct an RTF file of the message to print out later
tell application "TextEdit"
activate
close every document saving no
-- Assemble the document
set docText to "Date:" & tab & messageSent & return
set docText to docText & "Subject:" & tab & messageSubject & return & return
set docText to docText & messageContent & return
log "DOCTEXT: " & docText
set aDocument to make new document at beginning of documents
set text of the front document to docText
-- Save the document as an RTF in the messageFileName
tell front document
save in messageFileName as "RTF "
end tell
end tell
else
log "Message from \"" & messageSender & "\" with subject \"" & messageSubject & "\" will not be processed."
end if
end repeat
end tell
-- Change the text item delimiter and return the existing ones
on SwitchDelimiterTo(delimiterList)
local x
set x to (get AppleScript's text item delimiters)
set AppleScript's text item delimiters to delimiterList
return x
end SwitchDelimiterTo
(* END SCRIPT *)
It successfully walks throught the selected messages, picks out the "right" ones (from a particular address and with a particular subject), makes a folder to store some information about the email, has TextEdit assemble a document from the email's text and has TextEdit save the text file.
It's my kludgey work-around for not being able to either 1) print to a PDF file in Mail.app or 2) have Mail.app save the message itself as an RTF. It would be the bee's knees to get either 1 or 2 working, but I'd settle for figuring out how to format the text in TextEdit more nicely. I'd like to get the strings "Subject:" and "Date:" bold-faced for starters, but I have no way of knowing how to tell TextEdit to do it via AS.
My first try was to try to "make new text" with certain font and size properties at the end of the "texts", but that was a flop. I tried the same thing with "attribute runs" and "paragraphs" with no joy. It seems that the only way to get text into a document is to assign it to the "document"'s "text" property. But then I'm left to wonder how to select bits of it to change the bits appearances (fonts and sizes).
I've been fiddling with AS and automating Mail.app and TextEdit.app for days now, and it's just as perplexing as when I started. Any insite that you folks monitoring this discussion group would be greatly appreciated. The flotsam of script examples I've dredged up with Google haven't been enlightening. I've got a copy of O'Reilly's _AppleScript - The Definitive Guide_, and it's been a tiny bit of help, but I'm drifting.
Thanks in advance for reading.

Similar Messages

  • Is it possible to change the sytem defined Error Message

    Hi All,
    Is it possible to change the sytem defined Error Message: "Reason codes with automatic charge-off are not permitted here" to Warning Message. If so, how can I search in which application area  this message defined in OBA5 screen?
    Other details for this issue:
    Message: Reason codes with automatic charge-off are not permitted here
    Message Class: F5,
    Message No: 605.
    Thanks
    Chandra

    Hi,
    Without investigating deeper for this specific error message, I can say that the messages that cannot be maintained through OBA5 will in some cases remain in the system even if maintained in OBMSG. If message is not allowed for change in OBA5 and there is no OSS note regarding this message, it means that SAP designed it this way. Changing the nature in OBMSG (which is not standard or recommended SAP operation) will not always save the problem; the message could be simply hard-coded in the program with 'E' attribute.
    Regards,
    Eli

  • How can I change the display of Inbox in my iPad's mail app- so that it takes up the full screen?

    How can I change the display of Inbox in my iPad's mail app- so that it takes up the whole screen, as opposed to just about one third; the other two thirds display the full text of the selected email?

    You can't change the display in the Mail app, if you are holding the iPad in landscape orientation then the left-hand third will be for navigation, and the right-hand two-thirds will be an email. If you hold the iPad in portrait orientation then the navigation section becomes a drop-down section.

  • When I downloaded the new Mavericks system, all of the many RSS feeds I had in my mail app deleted. How do I get these back?

    When I downloaded the new Mavericks system, all of the many RSS feeds I had in my mail app deleted. How do I get these back?

    You can redownload most iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store        

  • Saving attachments to Time Capsule disk from mail.app

    I'm in a small business enviroment where we use the Time Capsule for both backup and and as a shared drive.
    But I'm having trouble saving attachments – pictures, worddocs etc, directly to the TC drive. If I save it to the desktop and then copy it to the TC drive everything is fine. Any suggestions ???
    I'm on a Macbook Pro OSX10.5.3

    Yes, it is possible to do that.
    There are downside to doing that.
    First, anything moved to the Time Capsule can't be backed up so the data will not be protected.
    Second, any data outside the backup makes it difficult for Time Machine to maintain free space for backups on the Time Capsule.
    My suggestion is to get an external disk drive and plug it into either the Mac or Time Capsule and use that for your data storage.

  • How do I find the location of a message found in a mail search?

    Can find emails, brand new or a couple of years old.  Have no idea how to out find where they are.
    There is no "Get Info." command to tell me how to locate the message(s).  Either in the mailboxes on my current "Mail 6.3" or, on a "Previous System" migrated over to my new MINI.
    It's logical this should not be hard for me to find.  Oh well.  Must be the old mans mail-pattern-blindness!
    Anybody know the answer?

    ... and if you command click on a search result it will be shown in the Finder.
    charlie

  • How do I change the default setting on messages I print in "Mail".

    I know I can use the Font box on the tool bar and change each individual message but I don't want to have to do this. I can't adequately see the present default setting. I am sure it is something simple, but being new to the Mac I can't seem to find the right solution.

    Go to Mail>Preferences>Fonts and colors and set your font permanently there.

  • How the **** do I get my old 6.something MAIL app back

    I just 'upgraded' from 6.something can't remember it was maybe 6.8, whatever came on my Mac Air 3 years ago.  I only upgrades because there is a piece of design software I want to use  that won't run on 6.  What ever happened to their vaunted backward compatability, how can folks be writing software that won't work on an operating system that is 3 years old?  I'm still using my G4 desktop with 4.11.  That probably goes back 8 years if I'm guessing right, and I understand it may be a bridge too far but working with software developers to orphan 3 year old machines is not the Mac I once knew.
    But I digress .
    I had no idea this 'upgrade' was going to screw with Mail and my Address Book.  They have ruined the search function in Mail by bringing it under spotlight.
    The new appearance is useless. It looks like Gmail which I hate.
    All I want is a succinct list view of messages and a dedicated robust search function that easily sets criteria for which fields to look in.
    The new version is hopeless. How do I go back. I didn't sign up for new Mail . I DONT WANT IT. I was so happy with my Mac experience, even though the air card on my Air won't connect I've been using it as a desktop machine.  And after seeing this new operating system, I don't even want a new Mac computer if I can't get the old MAIL back.
    MAybe late to the party here and sorry to fill the question up with observations, but these suppport communities are equally useless to search, have a lousy interface, I can never figure out how to find my own threads nevermind ones where the issue might already have been discussed.  Now they have just made the MAIL application as bad as their support forum.
    Thanks,
    Brian

    Bee,
    thanks for that.  I never have a clue when 'preferences' will be useful anymore.  I went to the spotlight preferences to try to fix the case sensitivity problem or figure out where you can now chose which field to restrict the search to in mail, and instead the only preferences they offer is how much gobbledy gook to search at once as if the default is likely to be every kind of file and its content in the computer.  That is the least likely search and their dogged adherence to the idea that this is what people want put me off spotlight from the moment they introduced it.
    And, silly me, my intuition when I didn't like the View was to look under the View menu.  And then go to the help menu and put in "view" in the search which, for reasons only apple knows does not bring up matches for "viewing" which  would have lead me to the correct answer - not only available in the preferences route but also located under Window>Viewing.  I don't get it, I don't know whay they would restrict a search in the help field to exclude the same word with a different ending, but when I search in my address book they have started adding snippets so if I search for "Rose" I'll get the name "Ambrose" and they put Ambrose and anything else they find that is alphabetically in front of Rose first, pushing what I really want hopelessly down the list.  This is as bad as phone searches when I search for Rose and get a bunch of florists.  That's fine, but give me anything that begins with Rose first instead of hopelessly buried hundreds of results down because of "AAA florist" and the like.
    Good search isn't about this unlimited access to your whole computer and treating everything the same. Rather its about restriction.  Searches with the most subtle and effective restrictions are where its at and apple seems to moving the wrong direction. This is why MAILs old search function worked so much better in my opinion, because all the stupid cellphone style searches for these that to search your mail (and the internet at the same time half the time) but offer no restrictions are a waste of my effort trying to use useless touch screens to put in search indecies.
    In this vein, and most unfortunately, changing to classic view did not bring up the classic search restrictors.  I get the search restriction bar, but it only offers choices amongst my mail boxeswhich simply duplices the choices I can make in the vertical pane on the left.  This bar used to be where you would get your field restrictions, i.e. entire message, subject, from , to.
    And then case sensitivity setting used to show up in a bar at the bottom.
    None of that stuff shows up.  The so  called "help" delivered with these apps says you can click an arrow to get those choices, but it doesn't say where the arrow is. I ca't find it. Why do I have to click an arrow. What happened to the restrictor bar.
    It is hard to calm down after I had a three month nightmare to get this 'upgrade' in the first place and the only thing it tells you about itself is you can used two fingers to scroll which is the least important feature Mac has ever developed for me. If, instead, a dialogue box pops up telling you how to revert if you don't like it, or if they think that telegraphs lack of belief in their new product, how about a dialogue box asking whether you are conservative user who doesn't like interface changes, etc. and then deliver settings accordingly instead of forcing you into their horrible google like regime and you having to pick your way through the minefields to get as much of your old useful interface back.
    It is of course great that folks like you will take the time to reply and that is the least exasperating and most hopeful part of this, although I would think that this is a place where apple would value feedback and mine is emphatically, go backwards.  The old MAIL and most importantly the old MAIL search distinguished Mac for me.  It was the most useful, fastest, functional mail reader and they should leave it alone.
    Yeah, I have a couple ideas like you ought to be able to set defaults for the inbox and the outbox so that it always searches the from field in the inbox and the to field in the outbox as the default and then you can change from there. but I never even bothered to voice that thought because, whenever they mess with something decent, they usually make it worse.  And having to click the field restriction was a small penalty to pay for their lack of foresight in that area.
    I search those from and to fields, respectively to inbox and outbox, more than any other and then subject is my next most searched field.  Instead they deliver a search engine whose default is entire message and no way to restrict it. I've got 60,000 messages that I regularly search and they have just torpedoed a big advantage. But what's worse, they did it because they have created some kind of incompatability between 6 and 7 that caused me to have to 'upgrade' in the first place.
    I think this attitude, that whatever apple comes up with will be the next great thing has overtaken their support of earlier apple platforms and backward compatability that assured you that when you decided to buy apple products you weren't going to be orphaned.  The mindset is more forcing you into their newer lines and designs.  We already pay a premium to buy mac products and I justfiy that because I'm going to get twice or three times the life out of the computer that I will out of an IBM.  But if they aren't supporting and encouraging software support to  continue for their line long enough for me to get those extra years and they keep diminishing my operating experience, then paying the premium doesn't make any sense.  I'm grossly disappointed because I've been Mac  since 1984 and they are trying their level best to alienate me -- and succeeding.
    Calm folks like you are their best weapon to keep folks like me on this platform and I do appreciate your response, but it is hard to calm down.
    Brian
    Brian

  • Is it possible to connect the same device to multiple stores?

    I would like to know if it is possible to have the same iPad (or iPhone) connected both to Apple app store and to a private store, in order to have the possibility to download some apps from one store and some apps from the other one.
    Regards,
    Ambra

    There are also "ad hoc" distribution:
    https://developer.apple.com/programs/ios/distribute.html
    and enterprise distribution:
    http://www.apple.com/business/accelerator/deploy/app-distribution.html
    Perhaps Ambra is referring to one of those when s/he refers to a "private" store.
    Regards.

  • How to know the name of a message catalog

    Hi ,
    is it possible to know the name of a message catalog at runtime
    (ie: 'myappli.cat' in place of qqlo_MessageCatalog) ????
    thanks.
    Cordialement.
    Patrice Bourdon
    Alliance Sante France
    Tel : (33) 02.54.60.26.27
    Fax : (33) 02.54.60.25.00
    e-mail: mailto:[email protected]
    web : http://www.alliance-sante.fr
    To unsubscribe, email '[email protected]' with
    'unsubscribe forte-users' as the body of the message.
    Searchable thread archive <URL:http://pinehurst.sageit.com/listarchive/>

    You can use @@PROCID And Object_Name() to get that value, for example
    Create Function dbo.FooGetMyOwnName ()
    Returns sysname
    AS
    Begin
    Declare @MyName sysname;
    Set @MyName = Object_Name(@@PROCID);
    Return @MyName;
    End;
    go
    Select dbo.FooGetMyOwnName();
    go
    sp_rename 'dbo.FooGetMyOwnName', 'FooIChangedMyName';
    go
    Select dbo.FooIChangedMyName();
    go
    Drop Function dbo.FooIChangedMyName;
    Tom

  • About the warning about changes message.

    Hi all,
    There is a messageChoice on the page,and the messageChoice must fire an action.But if the action is fired,then I click on the other tab or link, warning about changes message will not occur and directly farward to the other page.Is that possible that popup the warning about changes message after the messageChoice's event was fired ?
    Thanks,
    binghao

    Hi,
    this question is hard to understand. I don't see a messageChoice component in ADF Faces, can you give more details to your usecase and the components involved
    Frank

  • Send and receive email using applescript without Mail.app?

    How could I use applescript to send an email and check the email on the same account without adding those addresses to Mail.app. I tried using the 'sendmail' terminal command and that works pretty well for sending but how do I receive?

    Everything about fetchmail is here.

  • Restrict the number of processed messages in a time interval

    Hi experts,
    i have one problem to solve.
    Is there a possibility to restrict the number of processed messages in single stack java pi 7.3 in some time intervals?
    My problem is, that i have to restrict the messages from being sent only from 8:00 to 18:00 and there are restricted numbers that i can send in 15 minutes.
    For example 2000 messages can be sent in 15 minutes, if more messages arive, they should be queued and be processed in the next 15 minutes.
    Thank you in advance.
    Richard

    You're right in thinking that the behaviour you describe looks wrong.
    Take a look at the QueueBrowser interface which can be used to inspect a queue. You get one using QueueSession.createBrowser(Queue). The QueueBrowser allows you to scan a queue without consuming the messages. However note that the state of the queue may change while you're observing it through the QueueBrowser so what you see might not always be a 100% accurate representation of the queue at any given time.
    Other things to check:
    - message selectors - are you setting a message selector on your queue receiver which is resulting in not all of the messages 'matching'.
    - expired messages - are you setting a time-to-live on the messages that you publish.
    Hope this helps,
    David Ingham
    http://www.arjuna.com

  • How can I move most used mail accounts to appear at the top of the list when I open my mail app?

    I have updated iPhone4 to IOS7 and now my mail accounts are in new order.   I have several accounts but a few that need to be the most visible.  Not sure how iPhone mail app is sorting them but it sorting it but definitely not alphabetically or by most used.  Anyway, I finally figured out how to reorder them to suit me and, since help wasn't found on forum, thought I'd share:
    Open Mail App, then use "Edit" from top right.  You'll see a 3-bar icon to the right of each mail account.  Use it to slide accounts up/down to where you want them.  Works also for any Gmail accounts you might have.
    Sometimes it's the simple things

    cor-el, thanks for the tip. While I certainly scoured Adobe's preference settings to look for something relating to that exact thing, I never went to their help site until I got your post. I found out that the floating toolbar appears because the PDF opens in'' Read Mode'', which you can turn off for all future documents by doing this:
    * Quit your internet browser
    * Launch Acrobat (or Reader)
    * Choose Edit>Preferences
    * Click on the Internet category on the left
    * Deselect “Display in Read Mode by default”
    * Click the OK button.
    * Relaunch Acrobat
    Something important to note, if you have both Adobe Acrobat and Adobe Reader, you need to do the above in both programs (same steps).

  • Emails sent through Mail 7.0 on Mac won't appear in the Sent folder in the Yahoo web browser or the Mail app for iPad.

    It seems that emails I send via Mail on my mac are stored only in Mail's Sent folder. These emails don't appear in the sent folder of Yahoo web browser, iPad Mail app, or the Y! Mail android app..
    I've tested to see whether my emails are actually sending properly, and they are. I just want to know why the Sent messages on my mac aren't appearing anywhere else. I've read similar issues to this but haven't yet found a reason or solution.
    Thanks in advance

    [edit] I dragged the email I sent through the MBP Mail app (under MAILBOXES > Sent > Yahoo!) to the highlighted Sent folder (YAHOO! > Sent), and now it shows up on all Yahoo Sent folders (iPad app, web browser, phone app). Not entirely solved the issue but will use web browser to sent future emails to keep everything in sync.

Maybe you are looking for

  • AppleTV + iTunes library on a NAS = Can't open file

    A while ago I moved my iTunes library onto a NSA (specifically a TimeCapsule). With an AppleTV (1) streaming video from my Mac Mini, which in turn was reading the files from the NAS.  This worked pretty much perfectly. Recently I bought a new NAS, th

  • PROBLEM IN DELETE THE PARKED INVOICE

    Dear cons     We have parked an invoice document. but we want to delete the document.at the time of deletion the system gives an error message" that Transfer table would lead to a duplicate record in CDPOS/CDPOS_UID.When the generated update module X

  • Need material document number

    Dear all,     I have an issue.  Inorder resolve it i need run a run aset up in OL1BW using the material document number. I have the process order, period, plant and material, but i need to find the corresponding material document number. Can anyone h

  • Color Laserjet 2600n Toolbox - Windows 7 64 Bit

    I'm having trouble finding the HP Toolbox.    I have a Color Laserjet 2600n.   OS is Windows 7 - 64 Bit.  When I print checks, I notice a slight shadowing of the numbers.  Thinking it may need cleaned, but I cant find my toolbox anymore and have to t

  • JavaScript and Adobe Flash player massage in webpage

    Hi all, I have difficulties surfing some of the pages. It either show Adobe Flash Player not available or javascript not present. I had on both plug-in and javascript but it still show the above massages. Especially i surf pages which require to logi