Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. [VB.NET 2010] Sending mail only works sometimes

[VB.NET 2010] Sending mail only works sometimes

Scheduled Pinned Locked Moved Visual Basic
csharpsharepointsysadminhelp
35 Posts 19 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • T The Mighty Atom

    So i have dll project. In its code, i have a bunch of functions i use very often in many of my forms applications. One of them is a Bug Reporter class. When called, a dialog appears with some controls. When the user has filled all the textboxes and made valid combobox selections, you click the Submit button which submits the information to my email address. But this only seems to work sometimes. I can't figure out why. I've made a simple forms application for others to try and test the Bug Reporter. I've posted it on another website and it only seems to work for some of my testers, others get errors. Here are some screenshots: http://entrod.sp-website.net/images/bug.jpg[^] http://img638.imageshack.us/img638/5442/96651911.png[^] So im baffled. What can i do to make this work everytime? I mean, what's the point of having a bug reporter if the bug reporter itself doesn't work properly? :confused: Here my email code, if it's needed:

    Private Sub bgwSender_DoWork() Handles bgwSender.DoWork

            mErrorOccured = False
    
            Try
                mm = New MailMessage
                With mm
                    .From = New MailAddress(tbEmail.Text)
                    .To.Add("My email address goes here")
                    .Subject = Me.Text
                    .Body = \_
                        tbProblem.Text & ControlChars.NewLine & ControlChars.NewLine & \_
                        "Bug type: " & cbbBugType.SelectedItem & ControlChars.NewLine & \_
                        "Windows version: " & cbbWindowsVersion.SelectedItem & ControlChars.NewLine
                    .IsBodyHtml = False
                End With
                smtp = New SmtpClient
                smtp.Host = "My SMTP server goes here"
                smtp.Send(mm)
            Catch ex As Exception
                MessageBox.Show(ex.Message)
                mErrorOccured = True
                mErrorMessage = ex.ToString
            End Try
    
          End Sub
    

    Virtual Space Shuttle Astronaut

    L Offline
    L Offline
    Luc Pattyn
    wrote on last edited by
    #2

    Hi, if by "it works sometimes" you mean it works all the time on some machines, and never on some other machines, then IMO the most likely cause is something is blocking your app's access to the mail server. It could be an AntiVirus/Firewall, or a (corporate) proxy server. Those would need extra settings, I don't have the details handy. I expect you will never get it solved 100%, so what I would recommend is a two-way approach: 1. try and solve it as much as possible. Figure out what needs to be done on Firewalls and proxy servers and document it. 2. provide an alternate approach, i.e. when sending the mail fails, show a dialog telling the user your app created a file that he should mail to you. FYI: each particular problem can be tackled by pasting the error message into the Google search box; whatever the error is, you're not the first to get it! :)

    Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

    Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

    T 1 Reply Last reply
    0
    • L Luc Pattyn

      Hi, if by "it works sometimes" you mean it works all the time on some machines, and never on some other machines, then IMO the most likely cause is something is blocking your app's access to the mail server. It could be an AntiVirus/Firewall, or a (corporate) proxy server. Those would need extra settings, I don't have the details handy. I expect you will never get it solved 100%, so what I would recommend is a two-way approach: 1. try and solve it as much as possible. Figure out what needs to be done on Firewalls and proxy servers and document it. 2. provide an alternate approach, i.e. when sending the mail fails, show a dialog telling the user your app created a file that he should mail to you. FYI: each particular problem can be tackled by pasting the error message into the Google search box; whatever the error is, you're not the first to get it! :)

      Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

      Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

      T Offline
      T Offline
      The Mighty Atom
      wrote on last edited by
      #3

      Yeah it always works on some machines and never on others. Usefull tips. I'll see what i can do. But the email code itself, is that alright? Im not missing anything? Should i enable ssl? What about credentials/default credentials?

      Virtual Space Shuttle Astronaut

      L 1 Reply Last reply
      0
      • T The Mighty Atom

        Yeah it always works on some machines and never on others. Usefull tips. I'll see what i can do. But the email code itself, is that alright? Im not missing anything? Should i enable ssl? What about credentials/default credentials?

        Virtual Space Shuttle Astronaut

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #4

        I'm not an e-mail expert, so far I get specific problems solved, but I don't have the universal answer (unless it is 42). Your code looks fine to me, however I know there are many things that may interfere, credentials would be one of them. e.g. it may work better (or take less code) when the e-mail client happens to be running. :)

        Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

        Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

        1 Reply Last reply
        0
        • T The Mighty Atom

          So i have dll project. In its code, i have a bunch of functions i use very often in many of my forms applications. One of them is a Bug Reporter class. When called, a dialog appears with some controls. When the user has filled all the textboxes and made valid combobox selections, you click the Submit button which submits the information to my email address. But this only seems to work sometimes. I can't figure out why. I've made a simple forms application for others to try and test the Bug Reporter. I've posted it on another website and it only seems to work for some of my testers, others get errors. Here are some screenshots: http://entrod.sp-website.net/images/bug.jpg[^] http://img638.imageshack.us/img638/5442/96651911.png[^] So im baffled. What can i do to make this work everytime? I mean, what's the point of having a bug reporter if the bug reporter itself doesn't work properly? :confused: Here my email code, if it's needed:

          Private Sub bgwSender_DoWork() Handles bgwSender.DoWork

                  mErrorOccured = False
          
                  Try
                      mm = New MailMessage
                      With mm
                          .From = New MailAddress(tbEmail.Text)
                          .To.Add("My email address goes here")
                          .Subject = Me.Text
                          .Body = \_
                              tbProblem.Text & ControlChars.NewLine & ControlChars.NewLine & \_
                              "Bug type: " & cbbBugType.SelectedItem & ControlChars.NewLine & \_
                              "Windows version: " & cbbWindowsVersion.SelectedItem & ControlChars.NewLine
                          .IsBodyHtml = False
                      End With
                      smtp = New SmtpClient
                      smtp.Host = "My SMTP server goes here"
                      smtp.Send(mm)
                  Catch ex As Exception
                      MessageBox.Show(ex.Message)
                      mErrorOccured = True
                      mErrorMessage = ex.ToString
                  End Try
          
                End Sub
          

          Virtual Space Shuttle Astronaut

          E Offline
          E Offline
          Estys
          wrote on last edited by
          #5

          Maybe adding some credentials would help, it's a common problem.

          smtp.Credentials = new System.Net.NetworkCredential(credentialUser, credentialPassword);

          Cheers sorry it's C#, translate to VB

          If you can read this, you don't have Papyrus installed

          D 1 Reply Last reply
          0
          • E Estys

            Maybe adding some credentials would help, it's a common problem.

            smtp.Credentials = new System.Net.NetworkCredential(credentialUser, credentialPassword);

            Cheers sorry it's C#, translate to VB

            If you can read this, you don't have Papyrus installed

            D Offline
            D Offline
            Dalek Dave
            wrote on last edited by
            #6

            It's the same isn't it?

            ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC League Table Link CCC Link[^]

            E 1 Reply Last reply
            0
            • D Dalek Dave

              It's the same isn't it?

              ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC League Table Link CCC Link[^]

              E Offline
              E Offline
              Estys
              wrote on last edited by
              #7

              The semicolon will cause errors :)

              If you can read this, you don't have Papyrus installed

              D 1 Reply Last reply
              0
              • E Estys

                The semicolon will cause errors :)

                If you can read this, you don't have Papyrus installed

                D Offline
                D Offline
                Dalek Dave
                wrote on last edited by
                #8

                oooh, how did I miss that! :shame:

                ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC League Table Link CCC Link[^]

                L F 2 Replies Last reply
                0
                • D Dalek Dave

                  oooh, how did I miss that! :shame:

                  ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC League Table Link CCC Link[^]

                  L Offline
                  L Offline
                  Luc Pattyn
                  wrote on last edited by
                  #9

                  CodeProject even has a smiley for you in your current situation: : - O yielding :-O

                  Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                  Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                  1 Reply Last reply
                  0
                  • T The Mighty Atom

                    So i have dll project. In its code, i have a bunch of functions i use very often in many of my forms applications. One of them is a Bug Reporter class. When called, a dialog appears with some controls. When the user has filled all the textboxes and made valid combobox selections, you click the Submit button which submits the information to my email address. But this only seems to work sometimes. I can't figure out why. I've made a simple forms application for others to try and test the Bug Reporter. I've posted it on another website and it only seems to work for some of my testers, others get errors. Here are some screenshots: http://entrod.sp-website.net/images/bug.jpg[^] http://img638.imageshack.us/img638/5442/96651911.png[^] So im baffled. What can i do to make this work everytime? I mean, what's the point of having a bug reporter if the bug reporter itself doesn't work properly? :confused: Here my email code, if it's needed:

                    Private Sub bgwSender_DoWork() Handles bgwSender.DoWork

                            mErrorOccured = False
                    
                            Try
                                mm = New MailMessage
                                With mm
                                    .From = New MailAddress(tbEmail.Text)
                                    .To.Add("My email address goes here")
                                    .Subject = Me.Text
                                    .Body = \_
                                        tbProblem.Text & ControlChars.NewLine & ControlChars.NewLine & \_
                                        "Bug type: " & cbbBugType.SelectedItem & ControlChars.NewLine & \_
                                        "Windows version: " & cbbWindowsVersion.SelectedItem & ControlChars.NewLine
                                    .IsBodyHtml = False
                                End With
                                smtp = New SmtpClient
                                smtp.Host = "My SMTP server goes here"
                                smtp.Send(mm)
                            Catch ex As Exception
                                MessageBox.Show(ex.Message)
                                mErrorOccured = True
                                mErrorMessage = ex.ToString
                            End Try
                    
                          End Sub
                    

                    Virtual Space Shuttle Astronaut

                    _ Offline
                    _ Offline
                    _Erik_
                    wrote on last edited by
                    #10

                    This code will only work if the computer where it is running can use the port 25. If this port is closed, then it will not work.

                    T 1 Reply Last reply
                    0
                    • _ _Erik_

                      This code will only work if the computer where it is running can use the port 25. If this port is closed, then it will not work.

                      T Offline
                      T Offline
                      The Mighty Atom
                      wrote on last edited by
                      #11

                      Thanks people. One more question: should i use my username and password for credentials or should that be the username and password of the sender? That part confuses me.

                      Virtual Space Shuttle Astronaut

                      L S T 3 Replies Last reply
                      0
                      • T The Mighty Atom

                        Thanks people. One more question: should i use my username and password for credentials or should that be the username and password of the sender? That part confuses me.

                        Virtual Space Shuttle Astronaut

                        L Offline
                        L Offline
                        Luc Pattyn
                        wrote on last edited by
                        #12

                        the sender's since he is logging into his mail provider, not yours. And he'd normally provide a separate username/password for that particular purpose, as they aren't going to be replaced regularly and really should be independent of his normal, interactive ones. Which is similar to how an app should access a database really. :)

                        Luc Pattyn [Forum Guidelines] [My Articles] Nil Volentibus Arduum

                        Please use <PRE> tags for code snippets, they preserve indentation, improve readability, and make me actually look at the code.

                        1 Reply Last reply
                        0
                        • T The Mighty Atom

                          Thanks people. One more question: should i use my username and password for credentials or should that be the username and password of the sender? That part confuses me.

                          Virtual Space Shuttle Astronaut

                          S Offline
                          S Offline
                          Simon_Whale
                          wrote on last edited by
                          #13

                          normally the user-name and password for the email account that you will send through

                          As barmey as a sack of badgers Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.

                          T 1 Reply Last reply
                          0
                          • S Simon_Whale

                            normally the user-name and password for the email account that you will send through

                            As barmey as a sack of badgers Dude, if I knew what I was doing in life, I'd be rich, retired, dating a supermodel and laughing at the rest of you from the sidelines.

                            T Offline
                            T Offline
                            The Mighty Atom
                            wrote on last edited by
                            #14

                            Won't DefaultCrendentials be enough then? If i understand correctly, DefaultCrendentials get the username and password of the sender's email client, right? Then there's not need for them to enter it?

                            Virtual Space Shuttle Astronaut

                            A 1 Reply Last reply
                            0
                            • T The Mighty Atom

                              So i have dll project. In its code, i have a bunch of functions i use very often in many of my forms applications. One of them is a Bug Reporter class. When called, a dialog appears with some controls. When the user has filled all the textboxes and made valid combobox selections, you click the Submit button which submits the information to my email address. But this only seems to work sometimes. I can't figure out why. I've made a simple forms application for others to try and test the Bug Reporter. I've posted it on another website and it only seems to work for some of my testers, others get errors. Here are some screenshots: http://entrod.sp-website.net/images/bug.jpg[^] http://img638.imageshack.us/img638/5442/96651911.png[^] So im baffled. What can i do to make this work everytime? I mean, what's the point of having a bug reporter if the bug reporter itself doesn't work properly? :confused: Here my email code, if it's needed:

                              Private Sub bgwSender_DoWork() Handles bgwSender.DoWork

                                      mErrorOccured = False
                              
                                      Try
                                          mm = New MailMessage
                                          With mm
                                              .From = New MailAddress(tbEmail.Text)
                                              .To.Add("My email address goes here")
                                              .Subject = Me.Text
                                              .Body = \_
                                                  tbProblem.Text & ControlChars.NewLine & ControlChars.NewLine & \_
                                                  "Bug type: " & cbbBugType.SelectedItem & ControlChars.NewLine & \_
                                                  "Windows version: " & cbbWindowsVersion.SelectedItem & ControlChars.NewLine
                                              .IsBodyHtml = False
                                          End With
                                          smtp = New SmtpClient
                                          smtp.Host = "My SMTP server goes here"
                                          smtp.Send(mm)
                                      Catch ex As Exception
                                          MessageBox.Show(ex.Message)
                                          mErrorOccured = True
                                          mErrorMessage = ex.ToString
                                      End Try
                              
                                    End Sub
                              

                              Virtual Space Shuttle Astronaut

                              A Offline
                              A Offline
                              allodoxaphobia
                              wrote on last edited by
                              #15

                              mail is an ugly thing and should be avoided at all costs :) First of: it is highly unreliable. It's not beause it was transferred to the mail server that it will actually ever arive at it's final destination. Secondly, as pointed out by others; the odds that the client machine can actually connect to your mailserver are against you and diminishing every year due to it being such a popular medium to harass people with commercials :) - the client must be connected to the internet - it must be allowed to access your mail server, which on a lan it usually isn't. - Recently a lot of anti-virus software and personal firewalls started blocking programs from sending out mail due to the high number of spambot malware. A better sollution would be to store your bug report locally first and then try to send it to a webserver via http. This method is used by all the big players and preferred over smtp (mail), because : - you have proof of delivery at the client side (so you can keep it stored as long as it was not delivered correctly) - http is more likely to be allowed (outgoing) from a corporate lan. If they can surf the internet, they can send you a bugreport - if antivirus would start blocking programs from using http calls a lot of things wouldn't work any more so chances of that happening in the future are slim. This increases the reliability othis sollution - you have standard sollutions at your disposal to handle this (web services, ajax, etc...)

                              1 Reply Last reply
                              0
                              • T The Mighty Atom

                                So i have dll project. In its code, i have a bunch of functions i use very often in many of my forms applications. One of them is a Bug Reporter class. When called, a dialog appears with some controls. When the user has filled all the textboxes and made valid combobox selections, you click the Submit button which submits the information to my email address. But this only seems to work sometimes. I can't figure out why. I've made a simple forms application for others to try and test the Bug Reporter. I've posted it on another website and it only seems to work for some of my testers, others get errors. Here are some screenshots: http://entrod.sp-website.net/images/bug.jpg[^] http://img638.imageshack.us/img638/5442/96651911.png[^] So im baffled. What can i do to make this work everytime? I mean, what's the point of having a bug reporter if the bug reporter itself doesn't work properly? :confused: Here my email code, if it's needed:

                                Private Sub bgwSender_DoWork() Handles bgwSender.DoWork

                                        mErrorOccured = False
                                
                                        Try
                                            mm = New MailMessage
                                            With mm
                                                .From = New MailAddress(tbEmail.Text)
                                                .To.Add("My email address goes here")
                                                .Subject = Me.Text
                                                .Body = \_
                                                    tbProblem.Text & ControlChars.NewLine & ControlChars.NewLine & \_
                                                    "Bug type: " & cbbBugType.SelectedItem & ControlChars.NewLine & \_
                                                    "Windows version: " & cbbWindowsVersion.SelectedItem & ControlChars.NewLine
                                                .IsBodyHtml = False
                                            End With
                                            smtp = New SmtpClient
                                            smtp.Host = "My SMTP server goes here"
                                            smtp.Send(mm)
                                        Catch ex As Exception
                                            MessageBox.Show(ex.Message)
                                            mErrorOccured = True
                                            mErrorMessage = ex.ToString
                                        End Try
                                
                                      End Sub
                                

                                Virtual Space Shuttle Astronaut

                                L Offline
                                L Offline
                                Lokanta_b
                                wrote on last edited by
                                #16

                                Your code looks fine. My suggestion is, try to assign Body content in a string and assign to .Body. I had similar problem years ago (in CDONT) and it resolved when I changed this way. Since then I am always careful. Hope this helps.

                                1 Reply Last reply
                                0
                                • T The Mighty Atom

                                  Thanks people. One more question: should i use my username and password for credentials or should that be the username and password of the sender? That part confuses me.

                                  Virtual Space Shuttle Astronaut

                                  T Offline
                                  T Offline
                                  Tom Chantler
                                  wrote on last edited by
                                  #17

                                  Further to _Erik_'s message, and by way of an FYI, a lot of ISPs in the UK block access to port 25 other than to their own smtp servers. e.g. I am on O2 broadband and I can NOT run my own smtp server; the only servers I can access via port 25 belong to O2. As you can imagine, this is a measure to stop spam.

                                  1 Reply Last reply
                                  0
                                  • T The Mighty Atom

                                    So i have dll project. In its code, i have a bunch of functions i use very often in many of my forms applications. One of them is a Bug Reporter class. When called, a dialog appears with some controls. When the user has filled all the textboxes and made valid combobox selections, you click the Submit button which submits the information to my email address. But this only seems to work sometimes. I can't figure out why. I've made a simple forms application for others to try and test the Bug Reporter. I've posted it on another website and it only seems to work for some of my testers, others get errors. Here are some screenshots: http://entrod.sp-website.net/images/bug.jpg[^] http://img638.imageshack.us/img638/5442/96651911.png[^] So im baffled. What can i do to make this work everytime? I mean, what's the point of having a bug reporter if the bug reporter itself doesn't work properly? :confused: Here my email code, if it's needed:

                                    Private Sub bgwSender_DoWork() Handles bgwSender.DoWork

                                            mErrorOccured = False
                                    
                                            Try
                                                mm = New MailMessage
                                                With mm
                                                    .From = New MailAddress(tbEmail.Text)
                                                    .To.Add("My email address goes here")
                                                    .Subject = Me.Text
                                                    .Body = \_
                                                        tbProblem.Text & ControlChars.NewLine & ControlChars.NewLine & \_
                                                        "Bug type: " & cbbBugType.SelectedItem & ControlChars.NewLine & \_
                                                        "Windows version: " & cbbWindowsVersion.SelectedItem & ControlChars.NewLine
                                                    .IsBodyHtml = False
                                                End With
                                                smtp = New SmtpClient
                                                smtp.Host = "My SMTP server goes here"
                                                smtp.Send(mm)
                                            Catch ex As Exception
                                                MessageBox.Show(ex.Message)
                                                mErrorOccured = True
                                                mErrorMessage = ex.ToString
                                            End Try
                                    
                                          End Sub
                                    

                                    Virtual Space Shuttle Astronaut

                                    G Offline
                                    G Offline
                                    Gareth pn
                                    wrote on last edited by
                                    #18

                                    Might be nothing to do with the problems you are having, but worth bearing in mind. I have seen problems with emails not getting through due to a line length limit. Some servers adhere to standards which define a maximum length of 998 characters and will not accept the incoming email.

                                    1 Reply Last reply
                                    0
                                    • T The Mighty Atom

                                      So i have dll project. In its code, i have a bunch of functions i use very often in many of my forms applications. One of them is a Bug Reporter class. When called, a dialog appears with some controls. When the user has filled all the textboxes and made valid combobox selections, you click the Submit button which submits the information to my email address. But this only seems to work sometimes. I can't figure out why. I've made a simple forms application for others to try and test the Bug Reporter. I've posted it on another website and it only seems to work for some of my testers, others get errors. Here are some screenshots: http://entrod.sp-website.net/images/bug.jpg[^] http://img638.imageshack.us/img638/5442/96651911.png[^] So im baffled. What can i do to make this work everytime? I mean, what's the point of having a bug reporter if the bug reporter itself doesn't work properly? :confused: Here my email code, if it's needed:

                                      Private Sub bgwSender_DoWork() Handles bgwSender.DoWork

                                              mErrorOccured = False
                                      
                                              Try
                                                  mm = New MailMessage
                                                  With mm
                                                      .From = New MailAddress(tbEmail.Text)
                                                      .To.Add("My email address goes here")
                                                      .Subject = Me.Text
                                                      .Body = \_
                                                          tbProblem.Text & ControlChars.NewLine & ControlChars.NewLine & \_
                                                          "Bug type: " & cbbBugType.SelectedItem & ControlChars.NewLine & \_
                                                          "Windows version: " & cbbWindowsVersion.SelectedItem & ControlChars.NewLine
                                                      .IsBodyHtml = False
                                                  End With
                                                  smtp = New SmtpClient
                                                  smtp.Host = "My SMTP server goes here"
                                                  smtp.Send(mm)
                                              Catch ex As Exception
                                                  MessageBox.Show(ex.Message)
                                                  mErrorOccured = True
                                                  mErrorMessage = ex.ToString
                                              End Try
                                      
                                            End Sub
                                      

                                      Virtual Space Shuttle Astronaut

                                      A Offline
                                      A Offline
                                      abhisheksingh156
                                      wrote on last edited by
                                      #19

                                      Public Function SendMailToDept(ByVal Fromm As String, ByVal Recipient As String, ByVal Cc As String, ByVal Subject As String, ByVal Body As String) As Boolean 'Sending Mail to multiple pepople coading by (Abhishek singh)abhishek_singh156@yahoo.com Dim mailstatus As Boolean = False Try ' Create a New blank MailMessage */ Dim mailMessage As MailMessage = New MailMessage() mailMessage.From = Fromm mailMessage.To = Recipient mailMessage.Cc = Cc 'mailMessage.Bcc = txtBcc.Text; mailMessage.Subject = Subject mailMessage.Body = Body mailMessage.BodyFormat = MailFormat.Html SmtpMail.SmtpServer = "144.1.14.3" (your server path) SmtpMail.Send(mailMessage) mailstatus = True Catch ex As Exception mailstatus = False End Try Return mailstatus End Function Public button_click()--------- Dim subjectmail, strreason as string subjectmail = "Please chek this mail" strreason="Error comes" Dim strmail as string strmail = SendMailToDept(abhisheksingh156@yahoo.com, abhishek_singh156@yahoo.com, abhisheksingh156@gmail.com, subjectmail, strreason) End Sub Thanks & Regards Abhishek Singh TATA STEEL(ITS) Livelihood system abhishek_singh156@yahoo.com 09709109796

                                      1 Reply Last reply
                                      0
                                      • D Dalek Dave

                                        oooh, how did I miss that! :shame:

                                        ------------------------------------ I will never again mention that I was the poster of the One Millionth Lounge Post, nor that it was complete drivel. Dalek Dave CCC League Table Link CCC Link[^]

                                        F Offline
                                        F Offline
                                        Fabio Franco
                                        wrote on last edited by
                                        #20

                                        You didn't miss that, it was VB's mistake not to understand semicolons.

                                        1 Reply Last reply
                                        0
                                        • T The Mighty Atom

                                          So i have dll project. In its code, i have a bunch of functions i use very often in many of my forms applications. One of them is a Bug Reporter class. When called, a dialog appears with some controls. When the user has filled all the textboxes and made valid combobox selections, you click the Submit button which submits the information to my email address. But this only seems to work sometimes. I can't figure out why. I've made a simple forms application for others to try and test the Bug Reporter. I've posted it on another website and it only seems to work for some of my testers, others get errors. Here are some screenshots: http://entrod.sp-website.net/images/bug.jpg[^] http://img638.imageshack.us/img638/5442/96651911.png[^] So im baffled. What can i do to make this work everytime? I mean, what's the point of having a bug reporter if the bug reporter itself doesn't work properly? :confused: Here my email code, if it's needed:

                                          Private Sub bgwSender_DoWork() Handles bgwSender.DoWork

                                                  mErrorOccured = False
                                          
                                                  Try
                                                      mm = New MailMessage
                                                      With mm
                                                          .From = New MailAddress(tbEmail.Text)
                                                          .To.Add("My email address goes here")
                                                          .Subject = Me.Text
                                                          .Body = \_
                                                              tbProblem.Text & ControlChars.NewLine & ControlChars.NewLine & \_
                                                              "Bug type: " & cbbBugType.SelectedItem & ControlChars.NewLine & \_
                                                              "Windows version: " & cbbWindowsVersion.SelectedItem & ControlChars.NewLine
                                                          .IsBodyHtml = False
                                                      End With
                                                      smtp = New SmtpClient
                                                      smtp.Host = "My SMTP server goes here"
                                                      smtp.Send(mm)
                                                  Catch ex As Exception
                                                      MessageBox.Show(ex.Message)
                                                      mErrorOccured = True
                                                      mErrorMessage = ex.ToString
                                                  End Try
                                          
                                                End Sub
                                          

                                          Virtual Space Shuttle Astronaut

                                          T Offline
                                          T Offline
                                          TheCodeMonk
                                          wrote on last edited by
                                          #21

                                          I had that EXACT same problem a ton of times when we first started using the SMTP libraries... For me, it was only doing it on machines that had Norton or McAfee anti-virus installed. Both of those did real time scanning of e-mail as it was sent out. I'm not sure if it actually "hijacked" the connections or if it blocked those connections so that all mail was forced to route through it's proxy, but as soon as I turned off real time mail scanning, it worked fine every time. Your code looks fine to me. Looks just like what I had when I was running into the same issues. I stripped mine all the way down to the bare minimums for testing.

                                          1 Reply Last reply
                                          0
                                          Reply
                                          • Reply as topic
                                          Log in to reply
                                          • Oldest to Newest
                                          • Newest to Oldest
                                          • Most Votes


                                          • Login

                                          • Don't have an account? Register

                                          • Login or register to search.
                                          • First post
                                            Last post
                                          0
                                          • Categories
                                          • Recent
                                          • Tags
                                          • Popular
                                          • World
                                          • Users
                                          • Groups