Applescript get text from mail message

Hi,
I've got a nested script that ideally would work with a multiple selection of emails. Most of the script does but I've recently found the need to add the sender's delivery address to the outgoing message. I've found a way to insert the clipboard but that leaves me only being able to send out one message at a time and I have to copy the address for each message to the clipboard first. I made a script to do that bit once I'd selected the text but this only works from Applescript Editor and not Quicksilver which is what I normally use.
So, what I'm hoping is someone would be able to help me with the a, select the right bit of text between Delivery address: and Instructions to merchant: of each message and have that work with Quicksilver and b, tell me why the following script only partially works from Quicksilver, i.e. the top bit, copy to clipboard, doesn't work.
Thanks.
tell application "System Events"
  tell application "Mail" to activate
  key code 8 using command down
end tell
tell application "Mail"
  set thesenders to {}
  set thesenderstext to ""
  set myaddress to the clipboard
  set theMessages to the selection
  repeat with eachMessage in the theMessages
  repeat with i from 1 to the number of items in eachMessage
  set theAccount to "[email protected]"
  set theSender to (extract address from (the reply to of (item i of eachMessage)))
  if thesenders does not contain theSender then
  set thesenders to {theSender}
  end if
  set replyName to (extract name from (the sender of (item i of eachMessage)))
  set titleCaseString to (do shell script "/bin/echo" & space & quoted form of replyName & space & "| /usr/bin/perl -p -e 's/(\\w+)/\\u\\L$1/g;'") as Unicode text
  set firstName to word 1 of titleCaseString
  end repeat
  set AppleScript's text item delimiters to ", "
  set thesenderstext to thesenders as rich text
  set AppleScript's text item delimiters to ""
  set newMessage to make new outgoing message
  set theSubject to "instructions"
  set theContent to "Dear " & firstName & ",
Thanks so much for your order.
You will receive a despatch notice by email when your order is sent.
Your  Order is being sent to:
" & myaddress & "
Kind Regards
Jim
  set newMessage to make new outgoing message with properties {subject:theSubject, content:theContent, visible:true}
  set theAttachment1 to POSIX file "/Users/Jim/qrcode.13177607.png"
  set theAttachment2 to POSIX file "/Users/Jim/qrcode.13177658.png"
  set theAttachment3 to POSIX file "/Users/Jim/qrcode.13177665.png"
  tell newMessage
  set visible to true
  make new to recipient with properties {address:thesenderstext}
  --make new bcc recipient at end with properties {address:theBccRecipient}
  make new attachment with properties {file name:theAttachment1} at after the last paragraph
  make new attachment with properties {file name:theAttachment2} at after the last paragraph
  make new attachment with properties {file name:theAttachment3} at after the last paragraph
  -- send
  end tell
  tell application "Mail"
  set a to selection
  repeat with s in a
  set flag index of s to -1 as integer
  end repeat
  set theSelection to the selection
  repeat with theMessage in the theSelection
  move theMessage to mailbox "orders" -- of account theAccount
  activate
  end repeat
  end tell
  end repeat
  set read status of every message of mailbox "orders" to true
end tell

Shoot! I wrote this huge reply and then quit Safari by accident. I'm too tired to type it all over again (I should install a keylogger).
Anyway, check out the screen shot of my workflow. the AppleScript section is where it xfers the URL from a text editor (BBEdit) to Safari. It's pretty dirty but it works.
http://www.jameskocsis.com/urlworkflow.jpg
post antother reply if you need more data on this process.
Good luck.
-James

Similar Messages

  • Get URL from Mail message to Safari

    I want to be able to email myself at home from work with a URL in the body of the message. I want a Mail rule and Automator (or applescript if necessary) to take that URL from the message body and send it to Safari which will go to the URL. The URL can be either a web page or downloadable file.
    Quad G5   Mac OS X (10.4.7)   4.5GB RAM

    Shoot! I wrote this huge reply and then quit Safari by accident. I'm too tired to type it all over again (I should install a keylogger).
    Anyway, check out the screen shot of my workflow. the AppleScript section is where it xfers the URL from a text editor (BBEdit) to Safari. It's pretty dirty but it works.
    http://www.jameskocsis.com/urlworkflow.jpg
    post antother reply if you need more data on this process.
    Good luck.
    -James

  • HT201269 I recently switched from 4S to Galaxy S4. I am not getting texts from iphone senders. When the message is sent it goes as a imessage. How do I fix this??

    I recently switched from 4S to Galaxy S4. I am not getting texts from iphone senders. When the message is sent it goes as a imessage. How do I fix this??

    Turn off iMessage on the iPhone as should have been done prior to switching devices.
    Settings > Messages > iMessage > OFF

  • I have the new iOS 7 and am getting texts from another family members phone and they are getting mine how do I disable this without changing accounts

    I have the new iOS 7 and am getting texts from another family members phone and they are getting mine how do I disable this without changing accounts

    Welcome to the Apple Community.
    You could simply set each device to only use a single telephone number (settings > messages > send & receive, but this isn't really an ideal solution since the other person can always change their settings and see your messages and send messages that appear as if they are from you. There is only one real solution and that's to have your own accounts.

  • Please Help: Automator to get text from Safari Reader into Text file

    Hello All,
    I was hoping that someone will be able to help me.
    I would like for automator to obtain article text from a website without me having to manually cut and paste it.
    I tried to put together a workflow to get text from webpage, but it unfortunatley get some information that I don't want for eg. Menu Bar Titles and additional links etc. What would be ideal is if I could only extract the data that shows when I use the Safari Reader function.  I have tried a jave Readability Script, but this also extract the same information. Is there anyway someone could please kindly help me out with a nice Applescript or something?
    If there is no way to do this, there could be another solution around this... if there was a way I could use automator to delete the first and last 10 lines of the text document.
    Again, any help will be much appreciated.
    Many thanks,
    VicandMeliJvR

    Hi David,
    Thank you for your feedback. I would be happy to use a screen capture program, but Quicktime X seems to only allow me to record audio and record the video separately. I will do this as a last resort, but it's a big pain to try to line up the video audio.
    Thank you! I will definitely do this if nothing else works.

  • I changed to an android and now cant get text from some iphone users any suggestions??

    I have just switched to an android and now am having problems getting text from some iphone users, and suggestions as to how I can fix this?

    Hi mango72860,
    Thanks for visiting Apple Support Communities.
    If you're not receiving text messages from iPhone users, see this article for help:
    iOS: Deactivating iMessage
    http://support.apple.com/kb/TS5185
    Best Regards,
    Jeremy

  • Stripping Attachments from Mail messages.

    Does anybody know of a utility for stripping out attachments from Mail messages so as to save storage space?

    Hey thanks for the suggestions.
    Firstly, embedded attachments can be dragged out of the email messages on Windows as they can on OS X.
    Getting our clients to work like this could be difficult as they all have 1024px screens and from what we've seen they always have their windows maximised (in fact most Windows users seem to do this). But we'll suggest it.
    Secondly, when you next plan to make an attachment be sure to use the menu or toolbar option for selecting an attachment. When the Choose File dialog appears you will see a checkbox in the lower left labeled "Use Windows friendly attachments." Be sure that option is checked.
    We do this but it still doesn't seem to work - maybe their MailMarshal software is causing this?
    Thirdly, be sure any attachment you send has the proper extension. For example, PDF files should have ".pdf", and JPEGs should have ".jpg" or ".jpeg" in order to be consistent with what Windows applications expect.
    Yes, we do this.
    Fourthly, often certain documents on OS X do not have an extension or the extension is slightly different, for example, Word documents may be ".docx" on the Mac, but need to be ".doc" in order for Word for Windows to open the document by double-clicking.
    Have come across this also.
    Fifthly, ZIP files should not normally be confused with junk. Your IT department may need to consider making some changes to their email filtering software.
    We don't have an IT department, and based on recent conversations with their IT guys, they're definitely not interested in taking suggestions on email security from Mac users!
    Will see how we go with getting our clients to work differently but I'd personally prefer to sort it our end - from their point of view it's a Mac issue and from what I can see I think they might be right.

  • Had iPhone and now have droid..cannot get texts from other iPhone users?

    Had iPhone and now have droid..cannot get texts from other iPhone users?

    barbara, a friend of mine give me her old iphone 4 and she get the an android phone so when i typing a text message still shows me she have a iphone, she did turning off iMessage but after she contact her cellphone carrier and unlock the old iphone 4 her number get unlicked from IOS so, trying turning off iMessage is not the solution ebcause we tried and did not work , the best solution is go to ur cellphone carrier and do the request to unlock ur previews iphone then you will see the change it

  • Switched to android and can't get texts from apple users, Switched to android and can't get texts from apple users

    switched to galaxy 3 and cant' get texts from people that used to imessage me.  I have tried everything but swtiching my phone number.

    If you no longer have access to your iPhone, you will need to contact Apple for help deactivating your phone number from their iMessage system so those with iPhones will send normal text messages to your phone number instead of iMessages.
    Reference: http://support.apple.com/kb/ts5185
    iOS: Deactivating iMessage
    Symptoms
    If you experience any of these symptoms, you may want to deactivate iMessage:
    You can't receive SMS on your non-Apple device when another person sends them using an iPhone.
    You can't send SMS to a non-Apple device because they send as an iMessage.
    Resolution
    If you experienced the symptoms above, your cellular phone number may still be registered with iMessage. When you turn iMessage on with your iPhone, iMessage registers your cellular telephone number.
    To deregister your phone number, tap Settings > Messages and turn iMessage off.
    If you can't deactivate iMessage after you perform the steps above or you can't access the iPhone, please contact Apple Support.

  • I unregistered my iphone but still am having issues getting texts from iphone users. Anyone know how to fix this?

    I unregistered my iphone but still am having issues getting texts from iphone users. Anyone know how to fix this?

    Turn off iMessage on the old iPhone.
    Restore the iPhone as new.
    Have the other iPhone users delete the current message thread, and start a new messae to you.
    Have the other iPhone users delete your contact, then re-add it.
    Go to ww.icloud.com and remove the device from your Find My iPhone.
    Go to appleid.apple.com and change your primary email address and/or password.
    Contact Apple Support at getsupport.apple.com for further assistance if these steps don't work.
    Wait about 30 days for the iMessage server to self-correct the issue.

  • I have the new iOS 7 and am getting texts from another family members phone and they are getting mine how to I disable this ??

    I have the new iOS 7 and am getting texts from another family members phone and they are getting mine how to I disable this ??

    You each need to have separate Apple IDs and separate user accounts. Better yet, separate computers as well.

  • When and how does the message context get removed from the message when we use pass thru send port

    Friends,
    i have a doubt regarding message context.
    Assume i have used XMLRecieve pipeline in the receive side to receive the message so that the message context is created. I.e properties are promoted/written.
    now if we use pass thru transmit pipe line at send side, how and when does the message context get removed from the message?? Since pass thru does not have any stages/components, how does the message context removed and sent out a pure message to destination???
     i mean what exactly happens here to remove the context??
    Ravindar

    Thanks for the reply.
    "The Context is created by the Adapter, regardless of any Pipeline or Pipeline Component.  It has nothing to do with PassThrough vs. XmlReceive, although XmlReceive will write Promoted Properties to the existing Context,
    as can any other Component."
    yeah yeah, adapter does create some properties in context. You are right, i am aware of it. I just missed to explain it clearly. what i meant is addition of context properties will not happen if pass thru used. Thanks its clear.
    "No.  The Context already exists on the Message when it comes from the MessageBox and
    is equally available to any Component in any Stage.  The Context that hits the Pipeline is whatever was last Persisted, either by a Receive Port or Orchestration.  It is not created by the XmlAssembler (XmlTransmit)"
    You are right , the context already exists on the message while it leaves the receive port, and once it persists
    to message box the context and message context gets stored in messages in relative tables.
    Now as you said the components get the message from the last persistence, assume i have a send port(with passthru)
    subscriber and a orchestration subsrciber for this message.
    Orchestration gets the message with context right!!
    if the send sendport(with passthru) also gets message along with context, then where is this context removed/demoted
    while sending it out?.  i guess as per SAAkhlaq said,
    here sendport(with passthru) should get a pure message without context as passthru used. 
    or is it that ultimately send adapter removes the context completely?
    or is it something like biztalk run time load the context from database into cache and both orchestration and send port gets pure message, and if needed they use context from cache???
    sorry i may be troubling you, but i am confused. i hope i am not creating any nuisance with this
    post.
    Ravindar

  • How to get text from column  labels in pivot using javascript?

    Hi, is it possible to get text from column labels in pivot using javascript? How?

    You don't get a response from a URLRequest, you get the response from a URLLoader:
    View this sample page for URLRequest and URLLoader and I think it'll make more sense to you.
    http://help.adobe.com/en_US/air/reference/html/flash/net/URLRequest.html#URLRequest()

  • How to get Text from (.txt) file to display in the JTextArea ?

    How to get Text from (.txt) file to display in the JTextArea ?
    is there any code please tell me i am begginer and trying to get data from a text file to display in the JTextArea /... please help...

    public static void readText() {
      try {
        File testFile = new File(WorkingDirectory + "ctrlFile.txt");
        if (testFile.exists()){
          BufferedReader br = new BufferedReader(new FileReader("ctrlFile.txt"));
          String s = br.readLine();
          while (s != null)  {
            System.out.println(s);
            s = br.readLine();
          br.close();
      catch (IOException ex){ex.printStackTrace();}
    }rykk

  • I have an iphone 4  I can get texts from all but I person. Why? They can get mine

    I have an iphone4  I can get texts from everyone but one person. They can get mine. This started all of a sudden. Any suggestions?

    the mute button is a switch you need to flip, not touch. if you look at it and see color, its on.

Maybe you are looking for

  • How can I Request a new App. that hasn't been made yet?

         I'm in a car club with many car enthusiasts that use there iPads, iPhones, and iPods on their cars. This is done by using a car programmer that can link with Apple devices by Bluetooth. These programmers  are designed to unlock your vehicles hid

  • Info needed on how to get list price for a given MATNR and pricing Conditio

    Hi All, Can some one help me in finding List price for a given MATNR and pricing condition type. Basically, i need info regarding the tables that i need to use for this purpose. Thanks in advance. Regards, Udaya. PS: All helpful answers will be rewar

  • OGG-00303

    GGSCI (ORACT03) 13> view report ext1 Oracle GoldenGate Capture for Oracle Version 11.1.1.1 OGGCORE_11.1.1_PLATFORMS_110421.2040 Windows x64 (optimized), Oracle 11g on Apr 22 2011 00:19:58 Copyright (C) 1995, 2011, Oracle and/or its affiliates. All ri

  • RE:  MTO Production Finish Date

    Hi, We have an MTO Scenario. Example below. Sales Order for Material A:  Delievery Date 01/01/2010 Production Order for Material A linked to above SO: Finish Date 01/03/2010. Now using the above data when I do an availability check on the Sales order

  • Problème suite à coupure de courant

    suite à des coupures de couyrant , je n'arrive plus à ouvrir Dreamwaever 8 . J'ai un message qui me dis de réinstaller le programme pour résoudre le problème , mais j'ai déjà réinstaller 2-3 fois (après avoir désinstaller le programme de l'ordinateur