Copying email content with AppleScript

I'm hoping someone out there can tell me what's going on here...
I'm trying to extract text from an email using an AppleScript.  The script is being called by a mail rule based on a particular sender.  The script I have cobbled together from a few online sources is:
tell application "Finder" to set ptd to "Macintosh HD:Users:Rob:Documents:Rob Woods Art:Vitec:Tasks:" as string
using terms from application "Mail"
          on perform mail action with messages theIncomingMessages for rule theRule
                    tell application "Mail"
                              repeat with each_message in theIncomingMessages
                                        set theText to content of theIncomingMessages
                                        set theFile to ptd & "Task " & (theIncomingMessages's id as string)
                                        set theFileID to open for access file theFile with write permission
  write theText to theFileID
  close access theFileID
                              end repeat
                    end tell
          end perform mail action with messages
end using terms from
What should happen is I get a text file at the location defined at 'ptd' called 'Task (id)'.  But I get nothing.  I know the rule is running OK as it also plays a sound only on that rule.
I'm banging my head now!  I'm running Snow Leopard if it makes any difference.
Thanks peeps.
Rob

In case it helps debug this, I've been messing around and with the message selected, if I apply rules from the menu, I get what I expected - a txt file with the content written out.  But it's only working because I have the message selected. 
Does that ring any bells?
Rob

Similar Messages

  • How do you block copying of content with createPDF??

    new user
    how do you block copying of content with createPDF??

    You'll need Acrobat Std. or Pro. to set security on a PDF document that disallows copying of the content.

  • Email content with newline from R/3 using XI.

    Hi all,
    I am trying to send email from R/3 using XI mail adapter.
    For content I am using a String in R/3 but the interpreter does not recognize the new line char \n embedded in the string.When the mail arrives it comes as a single line.
    What is the right way to build the string so that line  break is maintained.
    Thanks ,
    Bikram

    Hello Bikram,
    i guess this a bit too late for you but for all the others having the same question:
    I think it depends in which format you send the email but for my scenario it worked with a user-defined function where you have something like that:
    String newline = System.getProperty("line.separator");
    return ("Sentence one." + newline + "Sentence two.");
    Hope that helps
    Mathias

  • Read email message with AppleScript

    Hi!
    I just used this tip to remotely sleep my MacBook Pro:
    http://www.tuaw.com/2008/04/07/applescript-control-your-mac-with-an-e-mail/
    Now I would like that when the message comes with the subject as System and the text as Read an applescript would read what I wrote after that.
    Example:
    From: Me
    Subject: System
    Text: Sleep
    -> The computer runs applescript sleep and sleeps (so far it's working)
    From: Me
    Subject: System
    Text: Read
    -> The computer runs applescript read (that's the problem)
    How do I point the AppleScript to the received message and make it start reading?
    Is there a way to also unlock the screen (screensaver uses password)?
    Tank-you in advance for any help!

    The trick here (and the part that TUAW doesn't cover in that article) is that when a Mail rule triggers an AppleScript it passes a list of relevant messages to the script.
    Once you have that it's easy to act upon the message content.
    So instead of the simple shutdown script you write something more like:
    using terms from application "Mail"
     on perform mail action with messages theSelectedMessages for rule theRule
      repeat with eachMessage in theSelectedMessages
       -- Process the current message
       -- YOUR CODE HERE
      end repeat
     end perform mail action with messages
    end using terms from

  • Highlighting field content with mouse

    All
    when I want to copy the contents of a field , I select the content with the mouse(it goes blue) and then I can copy (ctrl+c). But in my R/3 system, if I copy the content with the mouse, it turns  blue all right but on releasing the mouse, the highlighted content defaults back to the original. (Meaning it's not highlighted anymore and can't be thus copied).
    Which suitable setting inside the R/3 will enable me to achieve this ?
    Thanks in advance
    **I have the workaround of using (shift+ keybd. arrows) to highlight and copy, but I would like to achieve this with help of the mouse.

    Shovon,
    Quick copy paste ir very helpful.
    The moment you highlight it, the contentis copied onto the clipboard.. and if you wnat to paste it in any SAP related input field, right click the mouse .. the content gets copied.. and if you wish to paste it in any other application like Word or excel you have to use Ctrl+V
    Hope this helps

  • "email contents" applescript in Safari

    I would like to know how to use in applescript with Safari the "email contents", I' tried it a script and nothing happens, I couldn't find documentation on it.
    Thanks.
    hdr

    If this is exists, why don't use it ?
    This script works fine, but I can't populate the recipient (email) :
    tell application "Safari"
         open location "http://www.apple.com/"
         delay 10
         email contents of document 1
    end tell
    regards
    hdr

  • Copy the contents of Jtabl with line breaks to Excel

    Hi every one,
    In my stand alone application,I am copying the contents of Jtable i.e contents having the line breaks(\n).
    While copying and pasting the contents to Jtable,instead of linebreaks, a square symbol is appearing in the excel along with the line break.line break functionality is happening,but the additional symbol(empty square box) is appearing.
    here is my code:
    S = (String) "\""+mProcessQuestionTestItemTable.getValueAt(rowsselected, colsselected[j])+"\""; S=S.replace("\r\n", "\n").replace("\n", "\r\n");
    stringbuffered.append(S);can anyone help me in this?
    thank you!!                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

    Hi,
    I want to copy the contents of Jtable(contents having Line breaks(\n)) and pasting to Excel.
    While pasting the contents to Excel, a box is appearing in the excel.
    To remove the empty square box, i tried the sample code:
    originalstr =(String)"\""+ mProcessQuestionTestItemTable.getValueAt(rowsselected, colsselected[j])+"\"";
    originalstr=originalstr.replace("\r\n", "\n").replace("\n", "\r\n");
    strngBuffere.append(S);
    There will be no box,If i copy the contents of Jtable and pasting in notepad.
    the box is appearing in Excel only.
    can you suggest something to solve this..
    Thank you.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How do you email contents of favorites folder without having to copy and paste each item in the folder individually?

    how do you email contents of favorites folder without having to copy and paste each item in the folder individually?

    Zip (compress) the folder before you send it.

  • TS3276 Outgoing Mail with attachment loses email content. Why

    Sometimes (only a few times) if I send an attachment with an email, the recipient does not receive the content of my email. The attachment is received but the email content is blank. Has anyone else experienced this? Any ideas how to overcome it?

    thanks dude.
    first fall you people forgive me for cross posting
    mailing
    i got answer here. anyways. thanks helping.

  • Oicnnot delete emails that show up in my inbox. The email says this message has no content with a date of 12/31/00. The emails keep multiplying in my inbox

    I cannot delete emails that show up in my inbox. The email says this message has no content with a date of 12/31/00

    I have this problem too.
    The entire email says
    ((No Sender)
    (No Subject)
    This message has no content
    Two are dated 12/31/69
    and one came in today at 8:34pm (This last one has a "2" next to it which may indicate there are two of them?)
    There is no trash icon on the screen and there doesn't appear to be ny way to delete them.
    How do I delete them?

  • When send email with emoticons to a pc user, emoticons show as an empty box. Also, email content has a symbol on every line. How to stop this from happening?

    When send email with emoticons to a pc user, emoticons show as an empty box. Also, email content has a > symbol on every line. How to stop this from happening?

    Dear Mr. Toad (my all-time favorite ride at Disneyland ;-) ..
    Thanks so much for your detailed reply.. my netbook is in the bedroom, turned off.. I (so far) only use it in the evening, in the bedroom.. I've saved your response, and will try your suggestions, and let you know if they solve the problem I described. I really appreciate you taking the time to post such a detailed reply..
    I can't answer your Thunderbird "configuration" questions, because I'm in the living room, using the crap Vista laptop, on which I plan to install Thunderbird, and then take Windoze Mail out in the street and drive over it a few times.. I'll get back to you one way or the other, and let you know if your instructions solved the problem, or not..
    I don't understand why Thunderbird "out of the box", so to speak, simply doesn't forward HTML emails with embedded graphics, (like Outlook Excess, and Winblows Mail do).. without having to go through those steps. I personally HATE HTML email, but over the years, it's become more and more prevelant.. so it's a problem I must fix..
    Thanks again..
    Harv..

  • Sending email with graphic included in email content

    Hi all,
            I have a scenario where i need to send an email along with attachment to customer,my objective is solved but only problem is i cannot send any graphic
    on email body , as i am using function module ZBSCANF001_SMTP_OUTBOUND,where i have to send the email content as text,so using the read_text function module to get the standard text where the text and the image resides,but the problem is,read_text function module returns the image in its include form and I get all the text and the include for graphic in my actual email.Please help me out with this.
    reward points for helpful answers.

    Hi Deepthee,
    check this out.
    Use FM SO_NEW_DOCUMENT_ATT_SEND_API1.
    Check program RSWNSENDMAIL1 to know how it works.
    Remember to check the settings in transaction SCOT for sending internet mails.
    cheers,
    Hema.

  • TS3899 Whenever I send a email from iPad mail app with an attachment from pages or numbers, the receiver is getting only attachment in the email. They are getting the email content. How to troubleshoot this issue.

    Whenever I send a email from iPad mail app with an attachment from pages or numbers, the receiver is getting only attachment in the email. They are getting the email content. How to troubleshoot this issue.

    Someone is probably sending spam with your address forged on the To: line.  Could be one of your old contacts with a Windows machine has a virus that's doing it.  It's also possible your e-mail account has been hacked, though I'd think such a hacker would be a bit more purposeful.
    For more information, see:
    http://www.reedcorner.net/guides/macvirus/is_it_malware.php#spam
    * Disclaimer: links to my pages may give me compensation, and should not be taken as endorsement of my services by Apple.

  • My emails do not print full content with Epson DX6000

    I can print Pictures and Word documents but email content does not print - even though 'Print Preview' looks OK

    To all who have responded to my query - thanks very much. Apparently what was obvious to others was not obvious to me - I did not make the connection that three dots implied a print option, especially since other email functions had their own displayed buttons in outlook. Cheers,

  • Copying a chart with legend from numbers into mail or pages

    Hi, I have created a chart in numbers that I want to send to a supplier via Mail.
    So I select the chart in Numbers and drag it across to the new email editing window of Mail. This works but for some odd reason the legend is not copied across.
    Has anyone experienced this?
    Am I doing something wrong?
    Many thanks in advance for your help,
    D.

    Hello
    - 1 - If I group the objects in a single one, I may paste the entire chart into Mail.
    - 2 - If objects are separated but selected together, only the graph object is pasted int0 Mail.
    - 3 - If I select the graphic object I may copy-paste it into Mail.
    - 4 - If I select only the block with labels I can' Copy it, I always get a bell signal.
    I tryed this 4th case hoping that I would be able to study its contents in AppleScript but, nada. I can't copy it.
    - 5 - Other missing feature, I can't drag and drop a Numbers objet out of the doc window. It seems that the Numbers team forgot to read Apple Human Guidelines.
    Yvan KOENIG (from FRANCE dimanche 7 octobre 2007 20:44:36)

Maybe you are looking for

  • Triggering SignalExpress

    I am rather new to LabView and I am trying to acquire and log data from a Tektronix TDS5054B o-scope using SignalExpress.  More specifically, I am running a pulsed experiment, with a rep-rate of roughly 1 min.  I am using all four channels and trigge

  • Reference Monitor Question

    I'm in the market for a new TV. My old 19" Toshiba still works, but the quality isn't there anymore. Still good enough though to view video on before burning to DVD. My questions are: -- Will a flat screen LCD be comparable in any way to the CRT for

  • My Treo 755p needs to be replaced

    I just love my Treo 755p because it syncs effortlessly to my Mac OS 10.4.  Time now to buy a new phone.  Can I put my old calendar, contact, and memo entries from the 755p to a new palm phone?  Anyone give me advice as to which phone to purchase that

  • MARC-HERKL

    HI Gurus, In which screen we can find this HERKL(country of origin) field while creating material master. Thanks in advance

  • Firefox suddenly changed so now the tabs are hidden and the taskbar at the bottom of the screen is gone completely. What happened and how can I get these back?

    Things have suddenly changed on my Firefox. My taskbar has disappeared completely from the bottom of the screen. How do I get it back?