Can't get message from mailbox in shell script

I'm using the shell-script workaround for the problem of creating messages from scripts run by a Mail rule. Can't seem to get the syntax right for getting a message passed from the main routine:
Main
<pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:800px">using terms from application "Mail"
on perform mail action with messages theMessages
repeat with eachMessage in theMessages
set theID to id of eachMessage
set theBox to name of mailbox of eachMessage
set theAccount to "none"
try
set theAccount to name of account of mailbox of eachMessage
end try
do shell script "osascript Users/dave/Library/Scripts/Applications/Mail/exp.scpt " & theID & " " & theBox & " " & theAccount
end repeat
end perform mail action with messages
end using terms from
using terms from application "Mail"
on run
tell application "Mail" to set sel to selection
tell me to perform mail action with messages (sel)
end run
end using terms from</pre>
Shell
<pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:800px">on run TheArgs
using terms from application "Mail"
set theID to item 1 of TheArgs
set theBox to item 2 of TheArgs
set theAccount to item 3 of TheArgs
if theAccount = "none" then
set theMessage to (message of mailbox theBox) whose id is (theID as integer)
else
set theMessage to (message of mailbox theBox of account theAccount) whose id is (theID as integer)
end if</pre>
The conditional is so I can test by selecting messages from either my Inbox or other boxes. Either way, though I get runtime errors like: "Can’t get «class mssg» of «class mbxp» \"INBOX\" of «class mact» \"David\" whose id of it = \"19111\". (-1728)"
I've tried variations, but nothing seems to work.
BTW, how does one view events or results in a shell script? Neither its window nor the main routine's show anything, and even "log" statements in the shell seem to go nowhere.

I think I understand what's going wrong. If I select a message in my Inbox, the shell statement
<pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:800px">set theMessage to (message 1 of mailbox theBox of account theAccount) whose id is (theID as integer)</pre>
works. If I select a message from an On My Mac box, though, I can't get theAccount in Main in the first place because there's no account associated with those boxes. That's why I set up the "try" in Main and the conditional in the shell. I see now that
<pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:800px">set theBox to name of mailbox of eachMessage</pre>
in Main yields only the name of the box -- any containers it may have are omitted. Therefore,
<pre style="font-family: 'Monaco', 'Courier New', Courier, monospace; overflow:auto; color: #222; background: #DDD; padding: 0.2em; font-size: 10px; width:800px">set theMessage to (message 1 of mailbox theBox) whose id is (theID as integer)</pre>
fails if there are any containers. So, I need a "set theBox" statement in Main that produces a proper path to the message, regardless of where it's located. If I can formulate that, a single "set theMessage" in the shell will suffice, without having worry about whether there's an account. I've experimented with "path to" and will continue casting about, but if the solution is apparent to you, please let me know.
BTW: Echo was a worthwhile "little diversion" for me, because it's led me to a better understanding of what "do shell script" does (i.e., it executes a UNIX command as if it was typed into Terminal) and why it solves the message-creation problem (i.e., it runs the named script as a process that's separate from Mail). I suppose that was obvious to you and many others, but it wasn't to me, despite reading what the AS Language Guide says about it, plus a few Google hits for "osascript." So thank you for that.
One thing I don't understand, though: If I change the command to "echo $1 $2 $3", nothing appears in Terminal. (I can produce files the way you showed just fine.)

Similar Messages

  • Got a new Samsung galaxy s3 and can't get messages from iphone users now. Don't have the old iphone to change the settings ! please help . need to know how I can get messages on my galaxy

    Can't get messages from iphone users on my new Samsung g allaxy and don't have my old iphone anymore ! Please help !

    Read here under no longer have device:
    http://support.apple.com/kb/ht5661
    Be aware, changing your Apple ID password doesn't always work, & can take up to 45 days to work.
    It's either that, or you call AppleCare & have them fix.

  • Lost my Iphone 4g, hooked up old 3gs, can't get messages from people who have me registered with ichat

    Anyone who I had previously used iChat with, can no longer send me texts now that I have had to downgrade back to a 3Gs.
    Lost my Iphone 4g, hooked up old 3gs, can't get messages from people who have me registered with ichat.
    My carrier (Rogers) says they have nothing they can do about it.
    Thanks in advance.

    Correction - iMessage, not iChat.  Too early....

  • Can't get messages from my gmail account to my ipod touch to show up

    Hello,
    My daughter's ipod touch does not allow her to receive her email messages from her gmail account on the ipod touch. What do I need to do to have this work. It was working before I updated my iphone to icloud. At the time our accounts were linked since them I have seperated our accounts.
    SS

    This may help:
    iPhone, iPad, or iPod touch - Gmail Help

  • Can't get messages from iPhone user on my android

    I have recently swapped my iPhone for an android but still have I pad. I am not receiving messages from friends with I phones. Any ideas?

    Go to: https://supportprofile.apple.com/MySupportProfile.do
    Log in if not already logged in.
    Click on "Edit Products"
    Click on the "X" to the right of the product.
    Click "Unregister"

  • How can I get OffLine ContentDB with Power Shell Script

    Hello All,
    How  can I get details of the all content database associated with specific Web application.  I am trying following command.
    Get-SPContentDatabase –WebApplication “http://spf2013dev1:3001”
    This is return results of database which are in ready state. I needs all the database which are in Offline status. Please post a comment.
    Thanks.

    Alternatively:
    $wa = Get-SPWebApplication http://webAppUrl
    foreach($db in ($wa.ContentDatabases | where {$_.Status -eq "Offline")){$db.Name}
    Trevor Seward
    Follow or contact me at...
    &nbsp&nbsp
    This post is my own opinion and does not necessarily reflect the opinion or view of Microsoft, its employees, or other MVPs.

  • HT1923 Trying to remove ITunes so I can reinstall getting message from windows installer /feature that you are trying to use is on a network resource that is unavailable? How do I correct same message when trying to install upgrade.

    Message receiving is from windows installer:the feature you are trying to use is on a network resource that is unavailable

    Many thanks.
    (1) Download the Windows Installer CleanUp utility installer file (msicuu2.exe) from the following Major Geeks page (use one of the links under the "DOWNLOAD LOCATIONS" thingy on the Major Geeks page):
    http://majorgeeks.com/download.php?det=4459
    (2) Doubleclick the msicuu2.exe file and follow the prompts to install the Windows Installer CleanUp utility. (If you're on a Windows Vista or Windows 7 system and you get a Code 800A0046 error message when doubleclicking the msicuu2.exe file, try instead right-clicking on the msicuu2.exe file and selecting "Run as administrator".)
    (3) In your Start menu click All Programs and then click Windows Install Clean Up. The Windows Installer CleanUp utility window appears, listing software that is currently installed on your computer.
    (4) In the list of programs that appears in CleanUp, select any Apple Software Update entries and click "Remove", as per the following screenshot:
    (5) Quit out of CleanUp, restart the PC and try another iTunes install using an iTunesSetup.exe (or iTunes64Setup.exe) downloaded from the Apple Website:
    http://www.apple.com/itunes/download/
    Does it go through properly this time?

  • Cryptography in networking,client can't get message from server but

    Hello We are developing a simple Networking project where we are chaining CipherStreams to ObjectStream. When client gets connected to the server the server will send initial message to client and flush (but here is the problem) but the client does not get the message and is waiting for the message input.readObject() it just stuck there, what is the reason??
    ---Server Code----
    server = new ServerSocket( 15000, 100 );
    while ( true ) {
    connection = server.accept();
    connection.setTcpNoDelay(true);
    // Get input and output streams.
    desEn.init(Cipher.ENCRYPT_MODE, desKey);
    //get the raw OutputStream
    outraw = connection.getOutputStream();
    //chain the OutputStream to the coutDES
    CipherOutputStream
    CipherOutputStream coutDES = new CipherOutputStream(outraw, desEn);
    //chain the coutDES CipherOutputStream to
    ObjectOutputStream of output
    output = new ObjectOutputStream(coutDES);
    String message = "SERVER>>>DES CONNECTION SUCCESSFUL!";
    output.writeObject( message );
    output.flush();
    -End of Server Code--
    -- Client code start-
    Cipher desEn = Cipher.getInstance("DES"); //encrypting
    Cipher Cipher desDe = Cipher.getInstance"DES");
    client = new Socket(servername, 15000);
    client.setTcpNoDelay(true);
    desDe.init(Cipher.DECRYPT_MODE,desKey);
    cinDES = new CipherInputStream(inraw, desDe);
    input = new ObjectInputStream(cinDES);
    // We got stuck here the program don't go beyond this line
    Object obj = input.readObject();

    Thank you for your suggestion. But I tried to chain the BufferedStream between ObjectStream and CipherStream. The problem still exit.
    In the c/s sides, there are two functions to use the socket. One is the protocol part which does the handshaking before everything is prepared. Then a JTextField object is enabled and it will also use the socket and the chained stream to commnicate with the other part.
    The concrete problem is strange, it seems there is some hidden buffer which holds the message. When a message is send and flush, it doesn't go to the net, instead it is hold somewhere until an other message is send and flush. So there are some delay. So in my code I have to use sendDate("\n") to push the useful message out into to net. And on the other side, eatBoundary() to get rid of the "\n" and then getMsg() to recieve the useful message.
    However, for some time the communiction stuck, both sides are waiting. But when you send another message, the previous and the new message appear on the other side. In the way, it is hard to implement the handshaking which requires reliable syncronization. You have met the same problem before? If you think it is not clear enough could you send me your email addr and I can send you the source code.
    my addr; [email protected]
    Thanks again!
    Best

  • Can't get messages from icloud

    I have me.com account and it was working fine, I tried to send and email with a big file attached but it could not send it. After that I delete the message and tried to send a new mail but it is working as it is reading mail but it doesn't do anything and I can't read my mail on my mac. I have Lion 10.7.3

    troubleshooting imessage http://support.apple.com/kb/ts2755
    about message http://support.apple.com/kb/HT3529

  • Can't get messages from certain contacts

    Can't send or receive messages to some of my contacts

    Hi there Dunlop14,
    You may find the troubleshooting steps in the article below helpful.
    iOS: Troubleshooting Messages
    http://support.apple.com/kb/ts2755
    -Griff W. 

  • How do how do I get imessages off I have a galaxy now and I need imessages off or I can't get messages from iphone user'sget imessages off I have a galaxy now and I need imessages off or I can't get messages from iphone user's

    Plz help

    Go to: https://supportprofile.apple.com/MySupportProfile.do
    Log in if not already logged in.
    Click on "Edit Products"
    Click on the "X" to the right of the product.
    Click "Unregister"

  • How can i get address from subroutine program in script window

    Hi All,
    I have a problem with my script that is can i go into debug mode in script with out using the print program, but i have script code which i want to see is in the separate subroutine pool program.
    Regards.
    Venkat N

    You can activate debugger in transaction SE71 - Script layout.

  • Am getting message from MacPro that my start up disc is full - but I can't find it and can't figure out what to do to help situation. I've been making a number of imovies, which generates junk files. help?

    I am getting message from MacPro that my start up disc is full - but I can't find this "start up disc" and can't figure out what to do to help situation. I've been making a number of imovies, which generates junk files and material that I should toss in the trash, but it is not clear to me  what items I can toss and which items I can't toss. Can you help? Using the imovie "help" support the system showed me under the menu item "go" where the "start up disc" should be - but that wasn't actually available on my menu!  Thanks for your help!

    Disk Utility 
    Get Info on the icon on Desktop
    Try to move this to the MacBook Pro forum
    Your boot drive should be 30% free to really perform properly. 10% minimum
    Backup, clone, use TimeMachine, use another drive for your projects and movies, replace and upgrade the internal drive even.

  • Hi, my iPhone was stolen and now i can't receive messages from people with iPhones. What do i do to fix this problem, and get my old messages? This has been a problem for 3 weeks!

    Hi, my iPhone was stolen and now i can't receive messages from people with iPhones. What do i do to fix this problem, and get my old messages? This has been a problem for 3 weeks!

    This won't get your old messages back but will help with new ones: https://selfsolve.apple.com/deregister-imessage

  • When I get messages from Barnes and Noble, the text is blank. If I hit reply or forward, I can then see the content. This only happens with Barnes and Noble. Any suggestions on how to view the content?

    When I get messages from Barnes and Noble, the text is blank. If I hit reply or forward, I can then see the content. This only happens with Barnes and Noble. Any suggestions on how to view the content?

    I'm sorry, but your sister, unless she had already turned on the "Find my iPhone" feature and the person who took the phone has not disabled it, is out of luck. She should report the theft to local police authorities, including the serial number of her iPhone. While her experience is unfortunate, there are good reasons why Apple cannot do anything else about it.
    I hope she gets her phone back.
    Best of luck.

Maybe you are looking for