Hi,
I am new to VB.net, and new to the forum - so hi to all...
I am starting from the beginning and learning the basics, and at the moment I am testing the feature of sending an email via the pressing of a button on a form. The app is simple and internal to my network, and would use my Outlook client and my Exchange server.
I have seen many examples on the web, but all of them generate errors.
The following seems to be the simplest, and generates only one error: {"Unable to connect to the remote server"}
Can anyone please guide me. I also think that I need to insert some references, which I haven't learnt yet - such as SMTPclient, or MailMessage. Do I need to "add" something?
Many thanks for all your patience and future help...
Loin
I am new to VB.net, and new to the forum - so hi to all...
I am starting from the beginning and learning the basics, and at the moment I am testing the feature of sending an email via the pressing of a button on a form. The app is simple and internal to my network, and would use my Outlook client and my Exchange server.
I have seen many examples on the web, but all of them generate errors.
The following seems to be the simplest, and generates only one error: {"Unable to connect to the remote server"}
VB.NET:
Imports System.Net.Mail
Public Class Form1
Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button3.Click
Dim Mail As New MailMessage
Mail.Subject = "test email"
Mail.To.Add("me@me.com")
Mail.From = New MailAddress("me@me.com")
Mail.Body = "Test email"
Dim SMTP As New SmtpClient("192.168.0.100")
SMTP.EnableSsl = True
SMTP.Credentials = New System.Net.NetworkCredential("myusername", "mypassword")
SMTP.Port = "25"
SMTP.Send(Mail)
MessageBox.Show("Your message was successfully sent.")
End Sub
End Class
Can anyone please guide me. I also think that I need to insert some references, which I haven't learnt yet - such as SMTPclient, or MailMessage. Do I need to "add" something?
Many thanks for all your patience and future help...
Loin