Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > iPhone, iPod and iPad > iPhone

Reply
 
Thread Tools Search this Thread Display Modes
Old Jan 13, 2009, 01:26 AM   #1
ViViDboarder
macrumors 68040
 
ViViDboarder's Avatar
 
Join Date: Jun 2008
Location: USA
SMS Alternative

I've been using my Ymail account to get push emails to my phone and emailing the appropriate SMS gateways for each carrier. This works fine for me, but there is one big problem. I have to ask everyone their carrier and then look up the gateway and then add it to my Address Book.

NOT ANYMORE!

I wrote an AppleScript to check all selected Address Book entries and automatically look them up and add them if a gateway is found.

This is my first AppleScript and I didn't know it was object oriented, so I know the code is long and ugly, but it works.

If anyone has a Mac and wants to SMSify their Address Book, copy this code and paste it into Script Editor. From there select any or all your Address Book cards and click run!

PS: I just change the gateways to the MMS gateways found on http://en.wikipedia.org/wiki/SMS_gateways to have those too, although I can't send MMS with Yahoo, only Gmail for some reason. :P

EDIT: Newer modified version by ephramz has been posted over on http://www.macosxhints.com/article.p...09070922403951 Thanks for keeping it alive and giving me credit too!

Code:
-- RUNS ON SELECTED ENTRIES
-- this script adds email addresses for selected AddressBook cards
-- for the SMS gateways associated with the cellphone number provided on the card
-- This script checks for and does not act on duplicates
-- May not work 100% if number was brought from another carrier


-- beginning of bash script command
set command to "curl \"http://www.whitepages.com/carrier_lookup?carrier=att&name_0=&number_0="
-- used for parsing the webpage
set astid to AppleScript's text item delimiters
set justBefore to "<td id=\"status_column\" valign=\"middle\""

tell application "Address Book"
	-- makes a list of all selected entries
	set mylist to selection
	-- iterates for each person
	repeat with this_person in mylist
		-- makes list of each phone number for this_person
		set phonesList to every phone of this_person
		-- iterates for each phone number
		repeat with phonenumber in phonesList
			-- if the phonenumber is a mobile number extract the number
			if label of phonenumber is "mobile" then
				-- gets the mobile number
				set theNumber to value of phonenumber
				-- makes mobile number URI compatable
				--set theNumber to do shell script "perl -e 'use URI::Escape; print uri_escape(\"" & theNumber & "\")';"
				-- removes spaces - and () and . from phone number
				set illegalCharacters to {" ", "-", "(", ")", "."} -- Whatever you want to eliminate.
				set replaceWith to ""
				repeat with thisChar in illegalCharacters
					set AppleScript's text item delimiters to {thisChar}
					set theNumber to text items of theNumber
					set AppleScript's text item delimiters to {replaceWith}
					set theNumber to theNumber as Unicode text
				end repeat
				theNumber
				-- adds the number and ending " to the command
				set theCommand to command & theNumber & "\""
				-- quotes the command to ensure & is executed fine
				set quotedCommand to quoted form of theCommand
				-- switches to bash and gets the source of the page as T
				set T to (do shell script "/bin/bash -c " & quotedCommand)
				-- begin parsing
				set AppleScript's text item delimiters to justBefore
				set lastPart to text item 2 of T
				set AppleScript's text item delimiters to "<td>"
				set X to text item 2 of lastPart
				set AppleScript's text item delimiters to "</td>"
				set carrier to text item 1 of X
				
				-- reset the delimiter
				set AppleScript's text item delimiters to astid
				-- creates the email address for the phone number
				set theEmail to ""
				if carrier is "Verizon" then
					set theEmail to theNumber & "@vtext.com"
				end if
				if carrier is "AT&amp;T/Cingular" then
					set theEmail to theNumber & "@txt.att.net"
				end if
				if carrier is "T-Mobile" then
					set theEmail to theNumber & "@tmomail.net"
				end if
				if carrier is "Cellular One" then
					set theEmail to theNumber & "@mobile.celloneusa.com"
				end if
				if carrier is "Alltel Wireless" then
					set theEmail to theNumber & "@message.alltel.com"
				end if
				if carrier is "Sprint PCS" then
					set theEmail to theNumber & "@messaging.sprintpcs.com"
				end if
				
				-- is there a dupe or no email found?
				set dupe to false
				
				-- if no email address found
				if theEmail is "" then
					set dupe to true
				end if
				
				-- checks all email addresses of the person for duplicates
				set emailList to every email of this_person
				repeat with existingMail in emailList
					if value of existingMail is equal to theEmail then
						set dupe to true
					end if
				end repeat
				-- if there are no duplicates, add the new email address
				if dupe is false then
					make new email at end of emails of this_person with properties {label:"mobile", value:theEmail}
				end if
				
				
			end if
		end repeat
	end repeat
	
	save addressbook
	
end tell
__________________
iMac 21" Late '09 8GB iPhone3G Jailbroken MacbookPro iPod v5.5, Ubuntu x64 tower & EeePC 900, Lenovo T400
WinMatrix Profile | UbuntuForums Profile | XDA Forums

Last edited by ViViDboarder; Aug 4, 2009 at 02:08 PM.
ViViDboarder is offline   0 Reply With Quote
Old Jan 13, 2009, 07:55 AM   #2
ppc750fx
macrumors 65816
 
Join Date: Aug 2008
I'll try this out in a bit. Looks good.

Glad to see that somebody other than me use those free gateways instead of paying the carriers.

I'm amazed you've managed to put up with YMail though ....
ppc750fx is offline   0 Reply With Quote
Old Jan 13, 2009, 05:50 PM   #3
ViViDboarder
Thread Starter
macrumors 68040
 
ViViDboarder's Avatar
 
Join Date: Jun 2008
Location: USA
Quote:
Originally Posted by ppc750fx View Post
I'll try this out in a bit. Looks good.

Glad to see that somebody other than me use those free gateways instead of paying the carriers.

I'm amazed you've managed to put up with YMail though ....
Yea, well it's the only one with Push service for my phone. It's pretty unreliable though. I get some of my messages hours later! How is that Push? When/if we get push Gmail, I'll switch that baby over. Also, like I mentioned, no MMS with Ymail, only with Gmail.

BEGGING for Push Gmail!!!
__________________
iMac 21" Late '09 8GB iPhone3G Jailbroken MacbookPro iPod v5.5, Ubuntu x64 tower & EeePC 900, Lenovo T400
WinMatrix Profile | UbuntuForums Profile | XDA Forums
ViViDboarder is offline   0 Reply With Quote
Old May 9, 2009, 04:35 PM   #4
gnestor
macrumors newbie
 
Join Date: May 2009
Awesome!!!

great work! i can't believe that someone conceived this, let alone figured it out. with mobile data on phones nowadays, why pay for SMS ever again???
gnestor is offline   0 Reply With Quote
Old May 9, 2009, 04:47 PM   #5
geekmommy4
macrumors 6502
 
Join Date: Feb 2008
Location: Texas
Once again, I wish that I had a Mac! Looks like a very clever solution!
__________________
32GB 3Gs Black iPhone
The Princess Geek - mostly links to my "how-to" articles
geekmommy4 is offline   0 Reply With Quote
Old May 9, 2009, 05:45 PM   #6
vega07
macrumors 65816
 
Join Date: Aug 2006
I am a complete noob. How do I execute/run this script?
vega07 is offline   0 Reply With Quote
Old May 9, 2009, 05:49 PM   #7
TuffLuffJimmy
macrumors G3
 
TuffLuffJimmy's Avatar
 
Join Date: Apr 2007
Location: Portland, OR
Quote:
Originally Posted by vega07 View Post
I am a complete noob. How do I execute/run this script?
Put it into the Applescript editor. I'm a little confused on how it works though...

Care to explain, OP? Does it all just go through your email address?
__________________
"Next PM I get from you about this, and it gets posted as my signature." --*LTD*
TuffLuffJimmy is offline   0 Reply With Quote
Old May 9, 2009, 07:50 PM   #8
Dhedgecock
macrumors newbie
 
Join Date: May 2009
Just did this to all of my contacts in my address book. Works like a charm!! Thanks!
Dhedgecock is offline   0 Reply With Quote
Old May 10, 2009, 11:41 AM   #9
ViViDboarder
Thread Starter
macrumors 68040
 
ViViDboarder's Avatar
 
Join Date: Jun 2008
Location: USA
Wow. After months people are interested, haha.

Yea, you just pasted in the Applescript Editor and hit run.

What it does:
I found a website that lets you look up carriers of cellphone numbers. Actually, I found several, but the one that I use has the number search term in the address so I could put it into my code.

Basically, it goes through all phone numbers in your address book, navigates to that website, finds the carrier name, and then it uses the email gateway to send SMS messages. I just put that in manually for each carrier that I could find the addresses for.

I basically wanted to come up with something to save me a ton of time and decided I'd share it. I'd be glad to take any suggestions if you have anything.
__________________
iMac 21" Late '09 8GB iPhone3G Jailbroken MacbookPro iPod v5.5, Ubuntu x64 tower & EeePC 900, Lenovo T400
WinMatrix Profile | UbuntuForums Profile | XDA Forums
ViViDboarder is offline   0 Reply With Quote
Old May 10, 2009, 02:40 PM   #10
Rob Mclovin
macrumors 6502
 
Join Date: Jul 2008
So what can you do with this? It just uses your email to let you receive texts for free?
Rob Mclovin is offline   0 Reply With Quote
Old May 11, 2009, 06:39 AM   #11
ppc750fx
macrumors 65816
 
Join Date: Aug 2008
Quote:
Originally Posted by Rob Mclovin View Post
So what can you do with this? It just uses your email to let you receive texts for free?
Vice versa.
__________________
Host:/ #rm -rf /var/forum/trolls
If only it were that easy...
ppc750fx is offline   0 Reply With Quote
Old May 11, 2009, 10:30 AM   #12
fishkorp
macrumors 68000
 
Join Date: Apr 2006
I'm sure many people will find this useful and thanks to the OP for that, but the logic in figuring out the provider is far from 100% accurate now. All the sites/tools used to determine that were based on certain providers having certain prefixes. With number porting now, that becomes an issue. For example, in Northeast Pennsylvania any of those services will determine that a 570-604-xxxx phone number belongs to T-Mobile. However, I have family with that prefix on AT&T, Verizon, and T-Mobile. So just a warning that this will not work 100% of the time now thanks to number porting. In most cases it'll still work, but if anyone's switched carriers in the last 5 or so years, you'll probably get undeliverable SMS emails.
fishkorp is offline   0 Reply With Quote
Old May 11, 2009, 10:13 PM   #13
ViViDboarder
Thread Starter
macrumors 68040
 
ViViDboarder's Avatar
 
Join Date: Jun 2008
Location: USA
Quote:
Originally Posted by fishkorp View Post
I'm sure many people will find this useful and thanks to the OP for that, but the logic in figuring out the provider is far from 100% accurate now. All the sites/tools used to determine that were based on certain providers having certain prefixes. With number porting now, that becomes an issue. For example, in Northeast Pennsylvania any of those services will determine that a 570-604-xxxx phone number belongs to T-Mobile. However, I have family with that prefix on AT&T, Verizon, and T-Mobile. So just a warning that this will not work 100% of the time now thanks to number porting. In most cases it'll still work, but if anyone's switched carriers in the last 5 or so years, you'll probably get undeliverable SMS emails.
Yea, I realize that. It works pretty well and if you get a returned message then you know you have to fix that one. If it were fool proof there'd be no reason for anyone to get SMS.
__________________
iMac 21" Late '09 8GB iPhone3G Jailbroken MacbookPro iPod v5.5, Ubuntu x64 tower & EeePC 900, Lenovo T400
WinMatrix Profile | UbuntuForums Profile | XDA Forums
ViViDboarder is offline   0 Reply With Quote
Old Jul 13, 2009, 05:14 PM   #14
gnestor
macrumors newbie
 
Join Date: May 2009
error: can't get text item 2 of ""

i'm getting an error at this line:

set lastPart to text item 2 of T

is anybody else getting this error? any suggestions?
gnestor is offline   0 Reply With Quote
Old Jul 13, 2009, 05:37 PM   #15
samcraig
macrumors G5
 
Join Date: Jun 2009
question.

using the email gateways is free outgoing. But you still need a text plan to receive a reply.

a) it will reduce the # of txt message you use stretching out your plan (i.e. 200 msgs will last longer since you're only getting, not sending

b) if the person emails you back (not texts) than it's moot anyway since email to email is free with unlimited data.

So it's a "send free" solution - not something to replace a plan...
samcraig is online now   0 Reply With Quote
Old Jul 15, 2009, 07:38 PM   #16
ViViDboarder
Thread Starter
macrumors 68040
 
ViViDboarder's Avatar
 
Join Date: Jun 2008
Location: USA
Quote:
Originally Posted by gnestor View Post
i'm getting an error at this line:

set lastPart to text item 2 of T

is anybody else getting this error? any suggestions?
Sorry, I don't really know what that's all about. It worked with me.

Quote:
Originally Posted by samcraig View Post
question.

using the email gateways is free outgoing. But you still need a text plan to receive a reply.

a) it will reduce the # of txt message you use stretching out your plan (i.e. 200 msgs will last longer since you're only getting, not sending

b) if the person emails you back (not texts) than it's moot anyway since email to email is free with unlimited data.

So it's a "send free" solution - not something to replace a plan...
Yea, it's send free. They go from emails to emails. The other person would have to pay for their incoming though.
__________________
iMac 21" Late '09 8GB iPhone3G Jailbroken MacbookPro iPod v5.5, Ubuntu x64 tower & EeePC 900, Lenovo T400
WinMatrix Profile | UbuntuForums Profile | XDA Forums
ViViDboarder is offline   0 Reply With Quote
Old Sep 10, 2009, 02:50 PM   #17
ViViDboarder
Thread Starter
macrumors 68040
 
ViViDboarder's Avatar
 
Join Date: Jun 2008
Location: USA
Update

A user took my script and posted it over at macosxhints.com (they gave me credit of course ).

There have been a few changes made by other users and updated versions can be found there.

http://www.macosxhints.com/article.p...09070922403951

Also someone has converted it to an address book plugin.
__________________
iMac 21" Late '09 8GB iPhone3G Jailbroken MacbookPro iPod v5.5, Ubuntu x64 tower & EeePC 900, Lenovo T400
WinMatrix Profile | UbuntuForums Profile | XDA Forums
ViViDboarder is offline   0 Reply With Quote
Old Jul 27, 2010, 10:32 PM   #18
sails
macrumors newbie
 
Join Date: Jul 2010
Number Portability

Data24-7 offers an inexpensive service where you can look-up the carriers for your phone numbers. It is number-portability-aware; if somebody changes carriers, their new carrier will be updated in their service within a few hours.

The website is: http://www.data24-7.com

Pricing is $12 per month, and $0.006 per phone number.
sails is offline   0 Reply With Quote
Old Jul 29, 2010, 08:28 PM   #19
ViViDboarder
Thread Starter
macrumors 68040
 
ViViDboarder's Avatar
 
Join Date: Jun 2008
Location: USA
Well at least that spam is somewhat relevant...
__________________
iMac 21" Late '09 8GB iPhone3G Jailbroken MacbookPro iPod v5.5, Ubuntu x64 tower & EeePC 900, Lenovo T400
WinMatrix Profile | UbuntuForums Profile | XDA Forums
ViViDboarder is offline   0 Reply With Quote

Reply
MacRumors Forums > iPhone, iPod and iPad > iPhone

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Similar Threads
thread Thread Starter Forum Replies Last Post
SMS Free - Send SMS worldwide for FREE! kotsoum iPhone and iPod touch Apps 20 Dec 11, 2013 03:04 AM
iPhone: SMS Helper Alternative? (Or a Text Message counting app?) J41994 Jailbreaks and iOS Hacks 4 Apr 15, 2013 10:31 PM
Searching for sms app that make purity receive sms almansouri iPhone and iPod touch Apps 0 Sep 26, 2012 04:37 AM
Double Sms Tone/ Sms Stutter Fixed gagandeep90 iPhone 2 Jun 3, 2012 02:15 PM

Forum Jump

All times are GMT -5. The time now is 11:29 PM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Copyright 2002-2013, MacRumors.com, LLC