3

There are dozens of conference call numbers stored at my computer. These numbers are all numbers, such as 40027683, no other characters. These numbers are saved in a txt file. enter image description here

Some of my users may need a number when they are trying to make a conference call with their clients. So every time the users require for a conference call number via emails, I'll reply back with a number.

Is there a way to reply those mails which requires for concall numbers automatically? I would like to try Mail, AppleScript and Automator.

I would like to ask Mail to run AppleScript when a new email (The subject or message contents contain the keyword "concall") was received, here is an example:

enter image description here

The AppleScript which I wrote will be run to invoke the first number from the txt file. The next time when another message arrived, Mail will run AppleScript to invoke the second number of the txt file. Is there any way to make it happen?

Any suggestion would be much appreciated.

  • Could you include the AppleScript you have so far in your question? You could put used codes into a different file. So when you receive another mail. You simply take the first code again. – LH16 Dec 21 '16 at 10:30
  • Sorry, I didn't make it clear. I have no any codes now. Because I don't know how to invoke the numbers from the txt file or how to invoke the number within the script. What I want to make it happen is: When a new email arrived (with the subject or content: concall ), Mail will run AppleScript to invoke the first line of the txt file. Then another mail arrived, Mail will run AppleScript to invoke the second line of the txt file. – Vincent Dec 21 '16 at 10:57
0

You can do it like this:

property the_numbers : {10000, 20000, 30000}
using terms from application "Mail"
    on perform mail action with messages theMessages for rule theRule
        repeat with i from 1 to count of theMessages
            tell application "Mail"
                set the_sender to sender of item i of theMessages
                set the_subject to subject of item i of theMessages
                set the_counter to item 1 of the_numbers
                -- make the outgoing message (the reply)
                set the_reply to make new outgoing message with properties ¬
                    {subject:"Re: " & the_subject, content:"Use this number-- " & the_counter}
                tell the_reply
                    make new to recipient at end of to recipients with properties {address:the_sender}
                end tell
                send the_reply
            end tell
            -- this is the step that deletes item 1 from the list 
            set the_numbers to items 2 thru -1 of the_numbers
        end repeat
    end perform mail action with messages
end using terms from

This works, but you'll have to do a little work to get your list of numbers into an AppleScript list. You'll put them up at the top, separated by commas, replacing my 10000, 20000, 30000.

I call the list of numbers "the_numbers". By calling it a property, we save the value of the_numbers from run to run. If you were to use my script as-is in place of your "Untitled 3" in the rule you've set up, the first time the script is called it will be working with {10000, 20000, 30000}. The next time it runs, the list will be {20000, 30000}. The next time it runs, it will be {30000}. It will also be {30000} for all subsequent runs. I am assuming/hoping that you have a very long list of numbers and you aren't going to run out.

A better script would let you know that the list of numbers was down to the last one.

  • Thank you so much, Christian. Your script does work for me. I don't know how to thank you. I want to buy you a dozen of beer. Can I pay 10$ for your script? Please let me how to transfer the money to you. – Vincent Dec 31 '16 at 7:56
  • You are very welcome. Knowing that I helped you is very satisfying and completely sufficient. You can check my profile for more information about me. – Christian Boyce Jan 4 '17 at 19:22

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .