smtp email using , window xp Guelph, Canada
  • 12 years ago
    Hi, I am trying to send email using SMTP. The code works on one machine, however, failure message appears on the other. Any clue what could be the reason!! The code is as below: Dim MyMailMessage As New MailMessage() 'From requires an instance of the MailAddress type MyMailMessage.From = New MailAddress("[email protected]") 'To is a collection of MailAddress types MyMailMessage.To.Add("[email protected]") MyMailMessage.Subject = "gmail" MyMailMessage.Body = "Test gmail email" 'Create the SMTPClient object and specify the SMTP GMail server Dim SMTPServer As New SmtpClient("") SMTPServer.Port = 587 SMTPServer.Credentials = New System.Net.NetworkCredential("[email protected]", "abc") SMTPServer.EnableSsl = True Try SMTPServer.Send(MyMailMessage) MessageBox.Show("Email Sent") Catch ex As SmtpException MessageBox.Show(ex.Message) End Try
  • 12 years ago
    Hi, What is the error you receive on the other machine? Is it a possible firewall issue? Si
  • 12 years ago
    The error is "Failure sending email". If it is a firewall issue, how should I handle it? Thanks, AJ
  • 12 years ago
    Hi, you have a try catch around the statement, if you could let us know the details of the exception, that would be useful. If it is a firewall issue, then you need to open the ports for the email server. Si

Post a reply

Enter your message below

Sign in or Join us (it's free).


Why not write for us? Or you could submit an event or a user group in your area. Alternatively just tell us what you think!

Our tools

We've got automatic conversion tools to convert C# to VB.NET, VB.NET to C#. Also you can compress javascript and compress css and generate sql connection strings.

“Before software should be reusable, it should be usable.” - Ralph Johnson