Quantcast
Channel: Objective Development Forums
Viewing all articles
Browse latest Browse all 4524

[AppleScript] Check for new emails and get content

$
0
0
Many times, we are required to simply open our emails to click on some link for confirmation purposes like when
1. activating/deactivating email accounts
2. activating/deactivating membership
3. activating/deactivating subscriptions
4. receiving notification emails with a link to see the details
etc

The simple script below will help you speed up the process.

How to use?
1. Bring up this script in LaunchBar
2. Press return

You will get the text content of the last email you received. You can then use basic LaunchBar features:
1. Press return key to see the text contents in large type
2. Press right-arrow key to see the contents in LaunchBar and then press return key on the url which you can recognize by its icon.


tell application "LaunchBar" to hide
tell application "Mail"
   set message_id to message id of (get first message of inbox)
   check for new mail
   delay 20
   set theNew_id to message id of (get first message of inbox)
   if message_id ≠ theNew_id then
      set theMessageText to content of (get first message of inbox)
      tell application "LaunchBar"
         activate
         set selection to theMessageText as text
      end tell
   end if
end tell


Note: I have set a delay of 20 seconds as per my needs to wait for the new incoming mail to arrive. Alternatively, you can do this:
1. Use "Get Mail in Background" from LaunchBar.
2. If you hear the "New Mail" sound, then run this script

tell application "Mail"
   set theMessageText to content of (get first message of inbox)
end tell
tell application "LaunchBar"
   activate
   set selection to theMessageText as text
end tell

Viewing all articles
Browse latest Browse all 4524

Trending Articles