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:
- 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
- An email address to send the text message from
The major US Carrier gateways are:
- AT&T: email@example.com
- Sprint: firstname.lastname@example.org
- Tmobile: email@example.com
- Verizon: firstname.lastname@example.org
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 = "email@example.com" Const password = "password" '****END OF CONFIGURATION Dim emailObj, emailConfig Set emailObj = CreateObject("CDO.Message") emailObj.From = fromEmail emailObj.To = "firstname.lastname@example.org" 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.
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.