How to send SMS text message from your PC

Sending a text message from a PC to your phone seems like a simple party trick (and it is) but there are many more practical and useful reasons for sending automated text messages.

To list a few:

  • Alert you to motion at your front door (package delivery)
  • Let you know the washer or dryer is finished
  • Inform you the party button was triggered
  • Notify you of suspicious activity on your local network
  • Inform you when your 3D printer has finished
  • And the list goes on...

Today I'm going to focus on the how to send a text message from your PC via email. Note: this method is for a windows operating system if you are using a MAC or Linux operating system the script method will need to be modified.

You need two pieces of information to start:

  1. the SMS gateway of the phone number you are sending the text to. A comprehensive list can be found here but I included the major US carriers below for easy reference
  2. An email address to send the text message from

The major US Carrier gateways are:

  • AT&T: number@txt.att.net
  • Sprint: number@pm.sprint.com
  • Tmobile: number@tmomail.net
  • Verizon:  number@vtext.com

Now that you have the gateway and an email address paste the following code into a new text file and substitute the "fromEmail", "password", and "emailObj.To" fields with your information. You also want to change "emailObj.Subject" and "emailObj.TextBody" to your own tailored message. Note: you can send to multiple phone numbers by including multiple numbers in the "emailObj.To" field separated by semicolons.

'****CONFIGURE THE "FROM" EMAIL ADDRESS AND PASSWORD


Const fromEmail = "address@gmail.com"
Const password = "password"

'****END OF CONFIGURATION

Dim emailObj, emailConfig
Set emailObj = CreateObject("CDO.Message")
emailObj.From = fromEmail
emailObj.To = "phone_number@txt.att.net"
emailObj.Subject = "Party"
emailObj.TextBody = "Party Button has been activated"

Set emailConfig = emailObj.Configuration
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserver") = "smtp.gmail.com"
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpserverport") = 465
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusing") = 2
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate") = 1
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/smtpusessl") = true
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendusername") = fromEmail
emailConfig.Fields("http://schemas.microsoft.com/cdo/configuration/sendpassword") = password
emailConfig.Fields.Update

emailObj.Send

Set emailobj = nothing
Set emailConfig = nothing

Once you finish making edits save the file as a .vbs file type. If you are not familiar with how to change file extensions, you can see an example here.

Conclusion

Now you have an operational text message script! All you have to do now is set it to be executed by whatever event you want. You can look here for an example of how to execute a .vbs script.