I created a program in VB to send text messages to cell phones a while back but never got it to work. I using my friends mail server(I had to block out the username and password when posting the code below, but his server works) to relay the message. Here is the class I made:
Imports System.Net.Mail
Public Class SendEmail
Public Sub SendEmailMessage(ByVal strFrom As String, ByVal strSubject As String, ByVal strMessage As String, ByVal PicFilePath As String, ByVal UserName As String, ByVal strServer As String, ByVal strPort As String, ByVal Password As String, ByVal strTo As String)
Dim auth As New System.Net.NetworkCredential
Dim count As Integer = 1
auth.UserName = UserName.TrimEnd
auth.Password = Password.TrimEnd
Dim mailmsg As New MailMessage(New MailAddress(strFrom.Trim()), New MailAddress(strTo))
mailmsg.Subject = strSubject
mailmsg.Body = strMessage
mailmsg.From = New MailAddress(strFrom.TrimEnd, "Security")
Dim sendemail As New SendEmail
'Smtpclient to send the mail message
Dim SmtpMail As New SmtpClient(strServer, strPort)
SmtpMail.Credentials = auth
SmtpMail.Credentials = auth.GetCredential(strServer, Convert.ToInt16(strPort), "login")
SmtpMail.Send(mailmsg)
'End If
End Sub
Public Sub SendFakeEmailMessage(ByVal login As String, ByVal pass As String, ByVal strTo As String, ByVal strServer As String, ByVal port As Integer, ByVal strFrom As String, ByVal strSubject As String, ByVal strMessage As String, ByVal file As String)
Dim auth As New System.Net.NetworkCredential
auth.UserName = login
auth.Password = pass
Dim MailMsg As New MailMessage(New MailAddress(strFrom.Trim()), New MailAddress(strTo))
MailMsg.Subject = strSubject
MailMsg.Body = strMessage
MailMsg.From = New MailAddress(strFrom, "Security")
'Smtpclient to send the mail message
Dim SmtpMail As New SmtpClient(strServer, Convert.ToInt16(port))
Dim sendemail As New SendEmail
SmtpMail.Credentials = auth
SmtpMail.Credentials = auth.GetCredential(strServer, Convert.ToInt16(port), "login")
SmtpMail.Send(MailMsg)
End Sub
End Class
The exception is being thrown during the Smtp.Send(MailMsg).
Now here is the rest of it. Sorry about the length:
Private Sub BtnSend_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnSend.Click
Dim sender2 As New SendEmail
Dim carriers(58) As String
carriers(0) = "@itelemigcelular.com.br"
carriers(1) = "@message.alltel.com"
carriers(2) = "@message.pioneerenidcellular.com"
carriers(3) = "@messaging.cellone-sf.com"
carriers(4) = "@messaging.centurytel.net"
carriers(5) = "@messaging.sprintpcs.com"
carriers(6) = "@mobile.att.net"
carriers(7) = "@mobile.cell1se.com"
carriers(8) = "@mobile.celloneusa.com"
carriers(9) = "@mobile.dobson.net"
carriers(10) = "@mobile.mycingular.com"
carriers(11) = "@mobile.mycingular.net"
carriers(12) = "@mobile.surewest.com"
carriers(13) = "@msg.acsalaska.com"
carriers(14) = "@msg.clearnet.com"
carriers(15) = "@msg.mactel.com"
carriers(16) = "@msg.myvzw.com"
carriers(17) = "@msg.telus.com"
carriers(18) = "@mycellular.com"
carriers(19) = "@mycingular.com"
carriers(20) = "@mycingular.net"
carriers(21) = "@mycingular.textmsg.com"
carriers(22) = "@o2.net.br"
carriers(23) = "@ondefor.com"
carriers(24) = "@pcs.rogers.com"
carriers(25) = "@personal-net.com.ar"
carriers(26) = "@personal.net.py"
carriers(27) = "@portafree.com"
carriers(28) = "@qwest.com"
carriers(29) = "@qwestmp.com"
carriers(30) = "@sbcemail.com"
carriers(31) = "@sms.bluecell.com"
carriers(32) = "@sms.cwjamaica.com"
carriers(33) = "@sms.edgewireless.com"
carriers(34) = "@sms.hickorytech.com"
carriers(35) = "@sms.net.nz"
carriers(36) = "@sms.pscel.com"
carriers(37) = "@smsc.vzpacifica.net"
carriers(38) = "@speedmemo.com"
carriers(39) = "@suncom1.com"
carriers(40) = "@sungram.com"
carriers(41) = "@telesurf.com.py"
carriers(42) = "@teletexto.rcp.net.pe"
carriers(43) = "@text.houstoncellular.net"
carriers(44) = "@text.telus.com"
carriers(45) = "@timnet.com"
carriers(46) = "@timnet.com.br"
carriers(47) = "@tms.suncom.com"
carriers(48) = "@tmomail.net"
carriers(49) = "@txt.att.net"
carriers(50) = "@tsttmobile.co.tt"
carriers(51) = "@txt.bellmobility.ca"
carriers(52) = "@typetalk.ruralcellular.com"
carriers(53) = "@unistar.unifon.com.ar"
carriers(54) = "@uscc.textmsg.com"
carriers(55) = "@voicestream.net"
carriers(56) = "@vtext.com"
carriers(57) = "@wireless.bellsouth.com"
For Each ext As String In carriers
sender2.SendEmailMessage("email", "", MessageBox.Text, "", "name of person", "mailserver.net", port#, "password", TxtPhone.Text + ext)
Next
End Sub
I obviously changed it around so i basically didn't give out my friends mail server and password but that part works. Anybody have any ideas?