Hi

I am using VB 2010 on a Windows 7 Home Premium PC. I can't get my my smtp code to send an email out. It always comes back with the error:

"The operation has timed out"

I have both a Google Mail account and a Sky Mail account both of which use the same port but can't get either to work. I have checked my firewall and the smtp port 465 is allowed and I can see the process going through the firewall.

I know the mail works fine as I am using Windows Live Mail which sends and receives no problem. The code I am using is below:

Private Sub btnAddAmount_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnAddAmount.Click
Dim message As New MailMessage
With message
.From = New MailAddress("myemail@sky.com")
.To.Add("test@gmail.com")
.Subject = "TEST FORM PROG"
.Body = "HI THERE"
End With
Dim emailClient As New SmtpClient("smtp.tools.sky.com")
With emailClient
.EnableSsl = True
.Port = "465"
.Credentials = New Net.NetworkCredential("johnsmith@sky.com", "johnsmith")
Try
.Send(message)
Catch ex As Exception
MessageBox.Show(ex.Message)
End Try
End With
End Sub

Any help would be great

Turns out that Sky have two smtp ports the other being 587. Popped this in and it works fine :-)

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.