Turn Phone Numbers into Email Addresses!

T-mobile, in their infinite wisdom of poor customer service, does not allow you to redirect standard SMS messages, nor indeed to block or filter them in anyway, claiming that they need the service to deliver status updates, for emergencies, etc. Meanwhile, I’ve never gotten anything but SPAM and stuff from text-happy friends, all of which I don’t want at 15 cents a pop.
So while I (anxiously) await the demise of SMS and its replacement with mobile email used by all, I’ve come up with an interim solution. Why pay $10 a month for unlimited texts when I already have the (much more useful) functionality of unlimited email support on my Pearl? So then, how to pipe email to SMS? Startup teleflip has a solution: you can send an email to [phone num]@teleflip.com and it will send an sms to their phone! If they reply, it comes back to your email! Now all that remains is populating your address book with entries for people’s SMS ‘email addresses’. Applescript to the rescue! The following script goes through your address book, and for anyone with a ‘Mobile phone number set, it make it into a new email address with the label ‘SMS’. It’s smart enough to not recreate the email address if you run it multiple times. Note that you might want to create a smart group of people without mobile phone numbers so that you can make sure you don’t have some people whose mobile numbers are mislabeled as something else.

tell application "Address Book"
	repeat with this_person in every person
			set the_number to ""
			repeat with i from 1 to the count of phone in this_person
				if label of phone [i] of this_person as string is "Mobile" then
					set the_number to value of phone [i] of this_person as string
				end if
			end repeat
			if the_number is not "" then
				set isAlreadySet to "0"
				repeat with i from 1 to the count of email in this_person
					if (value of email [i] of this_person as string) ends with "@teleflip.com" then
						set isAlreadySet to "1"
					end if
				end repeat
				if isAlreadySet is "0" then
					make new email at end of emails of this_person with properties {label:"other:", value:my stripSymbolsAddEmail(the_number)}
				end if
			end if
		end repeat
	end tell

	on stripSymbolsAddEmail(inputText)
		set theSymbols to "().- "

		set prevTids to AppleScript's text item delimiters
		repeat with i in theSymbols
			set AppleScript's text item delimiters to i
			set inputText to inputText's text items
			set AppleScript's text item delimiters to prevTids
			set inputText to inputText as text
		end repeat
		if character 1 of inputText is not "1" then
			set inputText to ("1" & inputText)
		end if
		set inputText to (inputText & "@teleflip.com")
		inputText
	end stripSymbolsAddEmail
	--> thanks to http://applescriptsourcebook.com/viewtopic.php?pid=47366 for this part!

Now just sync up with your blackberry and you can send free texts. I only have a few friends who text me a lot, so I just sent them a text telling them to use this address to text me. Presumably, this would work great on the iPhone as well. Word.

Update: Apparently Pocketmac for Blackberry isn’t smart enough to sync anything email addresses labeled other than ‘work’, ‘home’ and ‘other’. Not sure if there’s a work arround other than changing those ‘SMS’ labels to ‘other’. Of course, this means we can’t simply check the label anymore since you might already have ‘other’ email addresses set (you can have multiple entries of a given label). Thus, I’ve updated the above script to check for a value ending in @teleflip.com instead. It now uses ‘other’ instead of ’sms’ as the label. Here’s an applescript to change all the old labels from ‘SMS’ to ‘other’ incase you are in my boat and already ran the script.

tell application "Address Book"
		repeat with this_person in every person
			repeat with i from 1 to the count of email in this_person
				if label of email [i] of this_person as string is "SMS" then
					set label of email [i] of this_person to "Other"
				end if
			end repeat
		end repeat
	end tell
	

Update 2: WordPress, my new host, was converting all my quotes in the above chunk of code to curly quotes automatically. Thanks! Unfortantly, pasting the code into Script Editor was thus causing an error. I’ve updated the post with manually hard-coded quotes to avoid this (thanks to this helpful post). Let me know if anyone knows a better way to get wordpress to stop being so smart.

16 Responses to “Turn Phone Numbers into Email Addresses!”

  1. Jason Says:

    I get errors running this script in Tiger .4.11

  2. whenderson Says:

    Stange Jason. Could you post a bit more detail on your error?

  3. whenderson Says:

    Ah. I’m guessing it’s a problem with the way quote marks paste into Script Editor. They got screwed up in the migration to WordPress, I think. Will fix and update asap…

  4. Code Posting in Wordpress (with Marsedit), Recap « Will Henderson Says:

    [...] anyone else find this weird?Preview.app now supports auto-reloading!Still no leopardHotel ChevalierTurn Phone Numbers into Email Addresses!Gmail Sucks LatelyRevisited: Facebook, Safari and External iFrames that need cookies « [...]

  5. AM Says:

    I was looking for something similar to this to take Fax numbers and use Internet Fax services such as Jfax, Efax, Maxemail etc. The address would be some thing like 18885551212@maxemailsend.com where 18885551212 is the fax number of the contact. However, I am not sure if I want to add a site specific info like Maxemail – or Teleflip in your case – to every one of my contacts. If the site/company goes out of business, I’m left with all these e-mail addresses that I would have to change manually or write another script.

    Would a better solution be to use an Addressbook plug-in to do this on the fly ? – so that I can click on a fax number ( mobile number in your case) and choose “send Fax/Teleflip via e-mail to”. The plug-in could just do the parsing etc on the fly and create an e-mail in Mail?

    Thanks for the idea though.
    AM

  6. whenderson Says:

    That would be cool but the point of this script was more for being able to send free SMS’s via an iPhone/Blackberry.

  7. Send multiple SMS and MMS via Mail or iPhone Mail | Techitorial Gadget Reviews and Tech Updates Says:

    [...] with sign-up; Wikipedia entry), you can send SMS and MMS messages via any newsletter client. This blog post contains AppleScript cipher that will parse mobile numbers in your Address Book, and add them as [...]

  8. JP Says:

    i mainly wanted to try this to send and receive MMS messages with my iphone. i have at&t service and own a pc. i can not figure out how to run the script. I have already set up a teleflip account. how do i go about finishing the process to send and receive MMS messages???

    Thanks in advance,
    JP

  9. DB Says:

    According to Wikipedia (http://en.wikipedia.org/wiki/Teleflip), Teleflip is no longer in existence. Any other services you know of?

  10. Setup Install Says:

    Windows application setup maker software in builds powerful, reliable executable EXE installation setup package.

  11. Data Recovery Reviews Says:

    Data recovery software demo provides quick file recovery of hard drives, USB removable media, digital camera card for Windows

  12. Heartburn Home Remedy Says:

    After reading through this article, I just feel that I really need more info. Could you suggest some resources please?

  13. Finishing Says:

    I just added you to my Google News Reader. Keep up the good work. Look forward to reading more from you in the future.

  14. Craig Matheson Says:

    Really good blog you have here. I found you on bing. I am going to add you to my rss feed reader.

  15. howto really build solarpanels Says:

    Greetings, I didn’t know where to contact you but your web design layout was messed up on firefox. Anyways, i just suscribd to your rss.

  16. Aurelia Says:

    wcrawford.org, how do you do it?

Leave a Reply