dcsimg
Results 1 to 13 of 13

Thread: [RESOLVED] SMTP Error

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    May 2013
    Posts
    295

    Resolved [RESOLVED] SMTP Error

    Hi All,

    I'm trying to write a quick program that will find my External IP and send a text message to my cell phone if it changes. I'm at the part where I need to send the text message and I'm generating an SMTP Error.

    I was wondering if you guys could take a look at my code and see where I made my mistake.

    Thanks,

    -NJ

    Name:  Program.jpg
Views: 103
Size:  56.2 KB
    Name:  Error.jpg
Views: 101
Size:  48.1 KB
    Code:
    Private Sub Button2_Click(sender As Object, e As EventArgs) Handles Button2.Click
    
            Dim mTo As String = Trim(PhoneNumTxbx.Text) & Trim(CellCarrierCmbx.SelectedItem.ToString())
            Dim mFrom As String = Trim(SenderTxbx.Text)
            Dim mSubject As String = Trim(SubjectTxbx.Text)
            Dim mMailServer As String = Trim(MailServerTxbx.Text)
            Dim mMsg As String = "Your External ID is: " & Trim(ExternalIPRtxbx.Text)
    
            Try
    
                Dim mySmtpClient As New SmtpClient(Trim(MailServerTxbx.Text))
                Dim message As New MailMessage()
                mySmtpClient.UseDefaultCredentials = False
                mySmtpClient.Credentials = New Net.NetworkCredential("My User ID", "My Password")
                mySmtpClient.Port = 587
                mySmtpClient.EnableSsl = True
    
                message = New MailMessage()
                message.From = New MailAddress(mFrom)
                message.To.Add(mTo)
                message.Subject = mSubject
                message.IsBodyHtml = False
                message.Body = mMsg
    
                mySmtpClient.Send(message)
    
                MessageBox.Show("The mail message has been sent to " & message.To.ToString(), "Mail", MessageBoxButtons.OK, MessageBoxIcon.Information)
    
            Catch ex As FormatException
                MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error)
    
            Catch ex As SmtpException
                MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error)
    
            Catch ex As Exception
                MessageBox.Show(ex.StackTrace, ex.Message, MessageBoxButtons.OK, MessageBoxIcon.Error)
    
            End Try
    
        End Sub
    Here is the code for the Combo Box with the cell carrier ID's

    Code:
            CellCarrierCmbx.Items.Add("@itelemigcelular.com.br")
            CellCarrierCmbx.Items.Add("@message.alltel.com")
            CellCarrierCmbx.Items.Add("@message.pioneerenidcellular.com")
            CellCarrierCmbx.Items.Add("@messaging.cellone-sf.com")
            CellCarrierCmbx.Items.Add("@messaging.centurytel.net")
            CellCarrierCmbx.Items.Add("@messaging.sprintpcs.com")
            CellCarrierCmbx.Items.Add("@mms.att.net")
            CellCarrierCmbx.Items.Add("@mobile.att.net")
            CellCarrierCmbx.Items.Add("@mobile.cell1se.com")
            CellCarrierCmbx.Items.Add("@mobile.celloneusa.com")
            CellCarrierCmbx.Items.Add("@mobile.dobson.net")
            CellCarrierCmbx.Items.Add("@mobile.mycingular.com")
            CellCarrierCmbx.Items.Add("@mobile.mycingular.net")
            CellCarrierCmbx.Items.Add("@mobile.surewest.com")
            CellCarrierCmbx.Items.Add("@msg.acsalaska.com")
            CellCarrierCmbx.Items.Add("@msg.clearnet.com")
            CellCarrierCmbx.Items.Add("@msg.mactel.com")
            CellCarrierCmbx.Items.Add("@msg.myvzw.com")
            CellCarrierCmbx.Items.Add("@msg.telus.com")
            CellCarrierCmbx.Items.Add("@mycellular.com")
            CellCarrierCmbx.Items.Add("@mycingular.com")
            CellCarrierCmbx.Items.Add("@mycingular.net")
            CellCarrierCmbx.Items.Add("@mycingular.textmsg.com")
            CellCarrierCmbx.Items.Add("@o2.net.br")
            CellCarrierCmbx.Items.Add("@ondefor.com")
            CellCarrierCmbx.Items.Add("@pcs.rogers.com")
            CellCarrierCmbx.Items.Add("@personal-net.com.ar")
            CellCarrierCmbx.Items.Add("@personal.net.py")
            CellCarrierCmbx.Items.Add("@portafree.com")
            CellCarrierCmbx.Items.Add("@qwest.com")
            CellCarrierCmbx.Items.Add("@qwestmp.com")
            CellCarrierCmbx.Items.Add("@sbcemail.com")
            CellCarrierCmbx.Items.Add("@sms.bluecell.com")
            CellCarrierCmbx.Items.Add("@sms.cwjamaica.com")
            CellCarrierCmbx.Items.Add("@sms.edgewireless.com")
            CellCarrierCmbx.Items.Add("@sms.hickorytech.com")
            CellCarrierCmbx.Items.Add("@sms.net.nz")
            CellCarrierCmbx.Items.Add("@sms.pscel.com")
            CellCarrierCmbx.Items.Add("@smsc.vzpacifica.net")
            CellCarrierCmbx.Items.Add("@speedmemo.com")
            CellCarrierCmbx.Items.Add("@suncom1.com")
            CellCarrierCmbx.Items.Add("@sungram.com")
            CellCarrierCmbx.Items.Add("@telesurf.com.py")
            CellCarrierCmbx.Items.Add("@teletexto.rcp.net.pe")
            CellCarrierCmbx.Items.Add("@text.houstoncellular.net")
            CellCarrierCmbx.Items.Add("@text.telus.com")
            CellCarrierCmbx.Items.Add("@timnet.com")
            CellCarrierCmbx.Items.Add("@timnet.com.br")
            CellCarrierCmbx.Items.Add("@tms.suncom.com")
            CellCarrierCmbx.Items.Add("@tmomail.net")
            CellCarrierCmbx.Items.Add("@tsttmobile.co.tt")
            CellCarrierCmbx.Items.Add("@txt.bellmobility.ca")
            CellCarrierCmbx.Items.Add("@typetalk.ruralcellular.com")
            CellCarrierCmbx.Items.Add("@unistar.unifon.com.ar")
            CellCarrierCmbx.Items.Add("@uscc.textmsg.com")
            CellCarrierCmbx.Items.Add("@voicestream.net")
            CellCarrierCmbx.Items.Add("@vtext.com")
            CellCarrierCmbx.Items.Add("@wireless.bellsouth.com")
    
            CellCarrierCmbx.Sorted = True

  2. #2
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,242

    Re: SMTP Error

    send a text message
    So you want to send an SMS text using an SMTP E-Mail client? Is that even possible (I avoid cell phones like the plague so it could be but it seems rather unlikely!)?

    If it is ...

    mySmtpClient.Port = 587
    mySmtpClient.EnableSsl = True

    ... are the settings for GMail. I would be very surprised if they applied to your own provider.
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  3. #3
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: SMTP Error

    Yeah you can't use SMTP to send text messages to phones... I think you're confusing SMS and SMTP. SMS is text message. SMTP is email.
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  4. #4
    PowerPoster techgnome's Avatar
    Join Date
    May 2002
    Posts
    32,456

    Re: SMTP Error

    -a side note: depending on your carrier, you can send SMS messages via email... some carriers have a feature where if you send an email to xxxyyyzzzz@carrier.com ... it'll transform it into a text message and send it.

    All that aside... I don't see anywhere where you specified the SMTP server to use...

    you told it "here's who I am, here's the port to use, and use SSL..." but you never gave it a server.

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  5. #5
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: SMTP Error

    Really? Huh, I've never heard of that. I don't think the carriers here in the UK have that feature, but perhaps they do and just don't advertise it very well.

    Anyway, he did specify the SMTP server in the constructor for the SmtpClient:

    Code:
      Dim mySmtpClient As New SmtpClient(Trim(MailServerTxbx.Text))
    Oh and to get a better error message description than the rather useless "Failure sending mail" message you get from the exception, you need to look at the InnerException, like so:

    Code:
    Catch Ex As Exception
       If Not Ex.InnerException Is Nothing Then
          MessageBox.Show(Ex.InnerException.Message)
       Else
         MessageBox.Show(Ex.Message)
       End If
    End Try
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


  6. #6

    Thread Starter
    Hyperactive Member
    Join Date
    May 2013
    Posts
    295

    Re: SMTP Error

    Quote Originally Posted by dunfiddlin View Post
    So you want to send an SMS text using an SMTP E-Mail client? Is that even possible (I avoid cell phones like the plague so it could be but it seems rather unlikely!)?

    If it is ...

    mySmtpClient.Port = 587
    mySmtpClient.EnableSsl = True

    ... are the settings for GMail. I would be very surprised if they applied to your own provider.
    You were right. I changed them to my provider(GoDaddy) and it still failed. Is there a way to expand the error message to get more detail?

    -NJ

  7. #7

    Thread Starter
    Hyperactive Member
    Join Date
    May 2013
    Posts
    295

    Re: SMTP Error

    Quote Originally Posted by chris128 View Post
    Really? Huh, I've never heard of that. I don't think the carriers here in the UK have that feature, but perhaps they do and just don't advertise it very well.

    Anyway, he did specify the SMTP server in the constructor for the SmtpClient:

    Code:
      Dim mySmtpClient As New SmtpClient(Trim(MailServerTxbx.Text))
    Oh and to get a better error message description than the rather useless "Failure sending mail" message you get from the exception, you need to look at the InnerException, like so:

    Code:
    Catch Ex As Exception
       If Not Ex.InnerException Is Nothing Then
          MessageBox.Show(Ex.InnerException.Message)
       Else
         MessageBox.Show(Ex.Message)
       End If
    End Try
    Thank you for the expanded error message.
    What I'm getting now is "Unable to connect to remote Server"

    Any Idea what I'm doing wrong?

  8. #8
    PowerPoster dunfiddlin's Avatar
    Join Date
    Jun 2012
    Posts
    8,242

    Re: SMTP Error

    my provider(GoDaddy)
    Go Daddy's your email provider? So the server's smtp.godaddy.com or similar? Failure to connect can mean any of several things. You got the server name, the username, the password or the port wrong. The server you named isn't an smtp server, the connectioon is down, ....
    As the 6-dimensional mathematics professor said to the brain surgeon, "It ain't Rocket Science!"

    Reviews: "dunfiddlin likes his DataTables" - jmcilhinney

    Please be aware that whilst I will read private messages (one day!) I am unlikely to reply to anything that does not contain offers of cash, fame or marriage!

  9. #9
    Bad man! ident's Avatar
    Join Date
    Mar 2009
    Location
    Cambridge
    Posts
    5,316

    Re: SMTP Error

    Quote Originally Posted by chris128 View Post
    Really? Huh, I've never heard of that. I don't think the carriers here in the UK have that feature, but perhaps they do and just don't advertise it very well
    As long as you know the carrier then it works in the UK

    Example number@t-mobile.uk.net

  10. #10

    Thread Starter
    Hyperactive Member
    Join Date
    May 2013
    Posts
    295

    Re: SMTP Error

    Quote Originally Posted by dunfiddlin View Post
    Go Daddy's your email provider? So the server's smtp.godaddy.com or similar? Failure to connect can mean any of several things. You got the server name, the username, the password or the port wrong. The server you named isn't an smtp server, the connectioon is down, ....
    Hi dunfiddlin,

    I Pinged the server smtpout.secureserver.net and found it.
    I double checked my userid and password by logging in manually via their website and was successful. Could there be something else?

    From Godaddy....
    Outgoing server (SMTP):
    smtpout.secureserver.net Ports: 80, 3535, 25, 465 (SSL)

  11. #11

    Thread Starter
    Hyperactive Member
    Join Date
    May 2013
    Posts
    295

    Re: SMTP Error

    Quote Originally Posted by ident View Post
    As long as you know the carrier then it works in the UK

    Example number@t-mobile.uk.net
    I Figured it out. I'm going through my work VPN. I shut down the VPN and it worked. Now I just have to figure out how to send the text the right way.

  12. #12

    Thread Starter
    Hyperactive Member
    Join Date
    May 2013
    Posts
    295

    Re: SMTP Error

    Ok I figured it out an I can now send Text Messages using VB.Net!! I had to select @txt.att.net instead of @mobile.att.net

    Woot!!!

  13. #13
    Pro Grammar chris128's Avatar
    Join Date
    Jun 2007
    Location
    England
    Posts
    7,604

    Re: [RESOLVED] SMTP Error

    Cool, glad you got it working and I learned you can send SMS messages via email as well lol modern technology...
    My free .NET Windows API library (Version 2.2 Released 12/06/2011)

    Blog: cjwdev.wordpress.com
    Web: www.cjwdev.co.uk


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width