Question How to send email from SmtpServer

Kyay Mon

Member
Joined
Sep 27, 2011
Messages
5
Programming Experience
1-3
I write the following code to send email. I don't get error message and also don't receive message. Please check for me.

Try
Dim SmtpServer As New SmtpClient()
Dim mail As New MailMessage()
SmtpServer.UseDefaultCredentials = False
SmtpServer.Credentials = New Net.NetworkCredential("myMail@company.com.sg", "password")
SmtpServer.Port = 80
SmtpServer.Host = "webmail.company.com.sg"
mail = New MailMessage()
mail.From = New MailAddress("myMail@company.com.sg")
mail.To.Add("receiver@gmail.com")
mail.Subject = "Test Mail"
mail.Body = "This is for testing SMTP mail"
SmtpServer.Send(mail)
Label1.Text = "mail send"
Catch ex As Exception
Label1.Text = ex.ToString
End Try
 
SmtpServer.Port = 80
Smtp server is likely not at port 80, and more likely at default port 25.
 
Thanks JohnH for your reply.
Our network admin said our smtp server port is 26.
So, I changed to 26.
But, the email cannot receive yet. :(
 
Have you checked with the network admin to see if the mail is getting blocked or classed as spam? Also worth checking any firewalls on your machine... i know certain ones which stop mailing which have caused me problems, although i think that would cause an exception but its worth a try. the setting on McAfee for instance is Prevent Mass Mailing Worms (or something similar).

This may also be a stupid question, but you do have access to the address receiver@gmail.com dont you?
 
Back
Top