Vb sending email

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jamesd0142
    Contributor
    • Sep 2007
    • 471

    Vb sending email

    [code=vb]
    'server address
    Dim client As New SmtpClient("ima p.uk.aol.com", 143)
    'username and password
    client.Credenti als = New Net.NetworkCred ential("my username", "mypassword ")
    Dim mm As New MailMessage("my emailaddress@ao l.com", "otheremailaddr ess@somewhere.c o.uk")
    'Set Subject
    mm.Subject = "Test"
    'set message
    mm.Body = "Test123"
    'html???
    mm.IsBodyHtml = False
    'send email
    Try
    client.Send(mm)
    'give error if any
    Catch ex As Exception
    'display error message
    MessageBox.Show (ex.ToString)
    End Try
    [/code]

    please look at the error message attached and help i dont no what this even means.
    thanks

    Hi if you cant read the attached file...
    [code=text]
    System.Net.Mail .SmtpException: Failure sending mail. ---> System.FormatEx ception: Smtp server returned an invalid response.
    at System.Net.Mail .SmtpReplyReade rFactory.Proces sRead(Byte[] buffer, Int32 offset, Int32 read, Boolean readLine)
    at System.Net.Mail .SmtpReplyReade rFactory.ReadLi nes(SmtpReplyRe ader caller, Boolean oneLine)
    at System.Net.Mail .SmtpReplyReade rFactory.ReadLi ne(SmtpReplyRea der caller)
    at System.Net.Mail .SmtpReplyReade r.ReadLine()
    at System.Net.Mail .SmtpConnection .GetConnection( String host, Int32 port)
    at System.Net.Mail .SmtpTransport. GetConnection(S tring host, Int32 port)
    at System.Net.Mail .SmtpClient.Get Connection()
    at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
    --- End of inner exception stack trace ---
    at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
    at Email.Form1.ema il1() in C:\Documents and Settings\Datadi ssUser\My Documents\Visua l Studio 2005\Projects\E mail\Email\Form 1.vb:line 28[/code]
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    Question moved to .NET Forum.

    Comment

    • Plater
      Recognized Expert Expert
      • Apr 2007
      • 7872

      #3
      it means instead of getting the 3digit success code from the SMTP server, it got back something else.
      Could be the number assoicated with "not allowed" or "we're shutting down" or "didn't understand your command"
      Are your username and password supplied correctly?

      You may have to packet watch to see the network traffic and see the actual reply message from the smtp server.


      EDIT: Your server might also be setup for SSL only, or to deny smtp usage unless you turn it on (gmail is like that)

      Comment

      • jamesd0142
        Contributor
        • Sep 2007
        • 471

        #4
        Originally posted by Plater
        it means instead of getting the 3digit success code from the SMTP server, it got back something else.
        Could be the number assoicated with "not allowed" or "we're shutting down" or "didn't understand your command"
        Are your username and password supplied correctly?

        You may have to packet watch to see the network traffic and see the actual reply message from the smtp server.


        EDIT: Your server might also be setup for SSL only, or to deny smtp usage unless you turn it on (gmail is like that)
        all sounds a little over my head...

        what is this ssl, and how do i turn smtp usage on?

        Comment

        • Plater
          Recognized Expert Expert
          • Apr 2007
          • 7872

          #5
          OK yeah
          hehe, I just looked closer at your code.
          You're trying to use their IMAP server and IMAP port as your STMP server.
          They're not the same.

          Use the SMTP server instead and try that.
          smtp.uk.aol.com
          and the correct port of 25


          Comment

          • jamesd0142
            Contributor
            • Sep 2007
            • 471

            #6
            thanks for the reply...

            i get this message now...

            [code=text]
            System.Net.Mail .SmtpException: Failure sending mail. ---> System.Net.WebE xception: The remote name could not be resolved: 'smtp.uk.aol.co m'
            at System.Net.Serv icePoint.GetCon nection(PooledS tream PooledStream, Object owner, Boolean async, IPAddress& address, Socket& abortSocket, Socket& abortSocket6, Int32 timeout)
            at System.Net.Pool edStream.Activa te(Object owningObject, Boolean async, Int32 timeout, GeneralAsyncDel egate asyncCallback)
            at System.Net.Pool edStream.Activa te(Object owningObject, GeneralAsyncDel egate asyncCallback)
            at System.Net.Conn ectionPool.GetC onnection(Objec t owningObject, GeneralAsyncDel egate asyncCallback, Int32 creationTimeout )
            at System.Net.Mail .SmtpConnection .GetConnection( String host, Int32 port)
            at System.Net.Mail .SmtpTransport. GetConnection(S tring host, Int32 port)
            at System.Net.Mail .SmtpClient.Get Connection()
            at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
            --- End of inner exception stack trace ---
            at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
            at Email.Form1.ema il1() in C:\Documents and Settings\Datadi ssUser\My Documents\Visua l Studio 2005\Projects\E mail\Email\Form 1.vb:line 28
            [/code]

            I also tried port 587 and got the same message...

            Comment

            • Plater
              Recognized Expert Expert
              • Apr 2007
              • 7872

              #7
              Are you connected to the internet?
              I was able to use that email server just fine.

              No troubles resolving or anything.
              Originally posted by NSLOOKUP
              Non-authoritative answer:
              Name: smtp.cs.com
              Addresses: 205.188.249.185 , 64.12.171.246, 64.12.180.144, 205.188.159.153
              205.188.159.185
              Aliases: smtp.uk.aol.com

              Comment

              • jamesd0142
                Contributor
                • Sep 2007
                • 471

                #8
                yes i have an internet connection, im actually using a server in work so its possible it may b blocked :S

                suppose its best to test this at home

                Comment

                • jamesd0142
                  Contributor
                  • Sep 2007
                  • 471

                  #9
                  [code=text]System.Net.Mail .SmtpException: Syntax error, command unrecognized. The server response was: CLIENT AUTHENTICATION REQUIRED. USE ESMTP EHLO AND AUTH.
                  at System.Net.Mail .MailCommand.Ch eckResponse(Smt pStatusCode statusCode, String response)
                  at System.Net.Mail .MailCommand.Se nd(SmtpConnecti on conn, Byte[] command, String from)
                  at System.Net.Mail .SmtpTransport. SendMail(MailAd dress sender, MailAddressColl ection recipients, String deliveryNotify, SmtpFailedRecip ientException& exception)
                  at System.Net.Mail .SmtpClient.Sen d(MailMessage message)
                  at Email.Form1.ema il1() in C:\Documents and Settings\Datadi ssUser\My Documents\Visua l Studio 2005\Projects\E mail\Email\Form 1.vb:line 28
                  [/code]

                  My login and password are correct

                  my code is as follows, any ideas???
                  [code=vb]
                  Private Sub email1()
                  'server address
                  Dim client As New SmtpClient("smt p.uk.aol.com", 25)
                  'username and password
                  client.Credenti als = New Net.NetworkCred ential("MyUsern ame", "MyPassword ")
                  Dim mm As New MailMessage("My Email", "SendtoEmai l")
                  'Set Subject
                  mm.Subject = "Test"
                  'set message
                  mm.Body = "Test123"
                  'html???
                  mm.IsBodyHtml = False
                  'send email
                  Try
                  client.Send(mm)
                  'give error if any
                  Catch ex As Exception
                  'display error message
                  TextBox1.Text = ex.ToString
                  'MessageBox.Sho w(ex.ToString)
                  End Try
                  End Sub
                  [/code]

                  Thanks

                  Comment

                  • Plater
                    Recognized Expert Expert
                    • Apr 2007
                    • 7872

                    #10
                    I'm not sure what kind of wierd business your code is doing?

                    220 cia-ma06.mx.aol.com ESMTP mail_cia-ma06.3; Wed, 14 Nov 2007 08:41:35 -0400
                    EHLO plater.mydomain .com
                    250-cia-ma06.mx.aol.com (ip-removed)
                    250-AUTH=LOGIN PLAIN XAOL-UAS-MB
                    250-AUTH LOGIN PLAIN XAOL-UAS-MB
                    250-STARTTLS
                    250-CHUNKING
                    250-BINARYMIME
                    250-X-AOL-FWD-BY-REF
                    250-X-AOL-OUTBOX-COPY
                    250 HELP
                    AUTH PLAIN
                    334 Username:
                    plater
                    334 Password:
                    plater
                    535 AUTHENTICATION FAILED
                    HELP
                    214-This is America Online mail version v120.9
                    214-Commands:
                    214- HELO EHLO MAIL RCPT DATA BDAT
                    214- RSET NOOP QUIT HELP
                    214-For more information contact postmaster@aol. com
                    214 End of HELP info
                    RSET
                    250 OK

                    I don't have a username/password for them but their server seemed to respond as normal. are you making sure your your username is "username@domai n.com" and not just "username" ?

                    Comment

                    • jamesd0142
                      Contributor
                      • Sep 2007
                      • 471

                      #11
                      Ye ive tried both, username and username+domain

                      wiered stuff goin on i think :P

                      did u get the above message using my code?

                      Comment

                      • Plater
                        Recognized Expert Expert
                        • Apr 2007
                        • 7872

                        #12
                        It doesn't seem to like AUTH LOGIN, either it doesn't really like base64, or you need to use an SSL connection
                        Code:
                        220 ciaaol-m05.mx.aol.com ESMTP mail_cia_aol-m05.8; Wed, 14 Nov 2007 11:11:28 -0500
                        EHLO <computername removed>
                        250-ciaaol-m05.mx.aol.com <IP removed>
                        250-AUTH=LOGIN PLAIN XAOL-UAS-MB 
                        250-AUTH LOGIN PLAIN XAOL-UAS-MB 
                        250-STARTTLS
                        250-CHUNKING
                        250-BINARYMIME
                        250-X-AOL-FWD-BY-REF
                        250-X-AOL-OUTBOX-COPY
                        250 HELP
                        AUTH login TXlVc2VybmFtZQ==
                        501 INVALID SASL FORMAT OR LENGTH
                        MAIL FROM:<MyEmail@mydomain.com>
                        556 CLIENT AUTHENTICATION REQUIRED. USE ESMTP EHLO AND AUTH.

                        Comment

                        Working...