Send a Text Message to a Smartphone via EMail
December 2016

One of the applications I developed needed to send a temporary password to a client when they had forgotten their password. After doing some research I found that I could use email to send the temporary password. I found some code at:

https://www.tutorialspoint.com/vb.net/vb.net_send_email.htm

I developed a VB.Net, Asp.Net, Visual Studio 2008 application that demonstrates the process. Click here to run the app.


The Demo App

The app asks for the Smartphone number and the carrier servicing the phone. I found a large list of carriers and added them to the dropdown box. Found at www.emailtextmessages.com.


A Partial List of Carriers

Carrier Lookup

If the user clicks the 'Carrier Lookup' link it launches a web site that will return the carrier associated with the entered phone number. In this case we would use @txt.att.net. for number 415-567-8900.

The Significant VB.Net Source Code

I created a Gmail account to test the app. The account's Username, Password and Server Host values are show in the source code. You will want to substitute your email account values.

The Significant VB.Net Source Code
Private Function DoSend(ByVal sPhoneTo As String, ByVal sCarrier As String, _
          ByVal sSubject As String, ByVal sMessage As String) As Boolean

' 2016/11/27 Function added by Larry Rebich using the HP-IQ804 while in Indio, CA
' 2016/11/29 Inspiration: https://www.tutorialspoint.com/vb.net/vb.net_send_email.htm

' 2016/11/29 A test email account was setup at GMail
' Change these to point to your email account and server host

Dim sUserName As String = "TipOfTheMonth.2016@gmail.com"
Dim sPassword As String = "TipOfTheMonth"
Dim sServerHost As String =
"smtp.gmail.com"

Try
Dim
Smtp_Server As New SmtpClient
Dim e_mail As New MailMessage()
Smtp_Server.UseDefaultCredentials =
False
Smtp_Server.Credentials = New Net.NetworkCredential(sUserName, sPassword)
Smtp_Server.Port = 587
Smtp_Server.EnableSsl =
True
Smtp_Server.Host = sServerHost
e_mail =
New MailMessage()
e_mail.From =
New MailAddress(sUserName)
e_mail.To.Add(sPhoneTo & sCarrier)
e_mail.Subject = sSubject
e_mail.IsBodyHtml =
False
e_mail.Body = sMessage
Smtp_Server.Send(e_mail)
'send it
Return
True

Catch

End
Try

End Function


Message sent successfully.


Error: No Phone Number Entered


Error: No Carrier Selected

Download VB.Net Code

Click here to download the VS2008 VB.Net source code [376k].

Previous Tip   Tip Index   Next Tip

Home

Updated 2016/12/02