Skip to content

Instantly share code, notes, and snippets.

@palaniraja
Created August 19, 2011 14:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save palaniraja/1156956 to your computer and use it in GitHub Desktop.
Save palaniraja/1156956 to your computer and use it in GitHub Desktop.
Applescript to send SMS (text) message when it receive an email on my office outlook.
(*
SMS me when new mail arrived.
Based on http://mattgemmell.com/using-growl-with-microsoft-outlook + SMS API from http://www.thekirankumar.com/blog/downloads/SMS-API2.0.zip
*)
-- Get a list of all "current messages" in Outlook.
tell application "Microsoft Outlook"
set theMessages to the current messages
end tell
-- Loop through the messages.
repeat with theMsg in theMessages
tell application "Microsoft Outlook"
-- Only Growl about unread messages.
if is read of theMsg is false then
set growl to true
set mysubject to get the subject of theMsg
set mysender to sender of theMsg
set mycontent to content of theMsg
-- Get an appropriate representation of the sender; preferably name, but fall back on email.
try
if name of mysender is "" then
set mysender to address of mysender
else
set mysender to name of mysender
end if
on error errmesg number errnumber
try
set mysender to address of mysender
on error errmesg number errnumber
-- Couldn't get name or email; we'll just say the sender is unknown.
set mysender to "Unknown sender"
end try
end try
else
-- The message was already read, so we won't bother Growling about it.
set growl to false
end if
end tell
-- Tell Growl to show our "New Mail" notification, with a custom title and description.
if growl is true then
tell application "Safari"
open location "http://localhost/SMS-API/smspalani.php?msg=" & mysender & " - " & mysubject & "-" & mycontent
end tell
end if
end repeat
<?php
error_reporting(E_ALL);
ob_implicit_flush(true);
//If you get Fatal error: Call to undefined function curl_init() , Then you need to enable the curl extension in php.ini
include_once "class.curl.php";
include_once "class.sms.php";
$smsapp=new sms();
$smsapp->setGateway('way2sms'); // you can set gateway to be '160by2' to use your 160by2 account;
echo "Logging in ... ";
$smsapp->login('xxxxxxxxx','********');
echo "Sending SMS ... ";
$result=$smsapp->send('xxxxxxxxx',strip_tags($_GET['msg']));
if($result=='true')
{
echo "Message sent";
}
else
{
echo "Error encountered : ".$smsapp->getLastError();
}
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment