How to send an email by authenticating with any mail server

If you want to send an email from an application that might not be on a server that allows relaying you can use the System.Net.NetworkCredential. Just add your account login and password and your email will route through the remote server.

    Dim sTo As String = “
    Dim sFrom As String = “
    Dim sSubject As String = “Using the new SMTP client.”
    Dim sBody As String = “Using this new feature, you can send an e-mail message from an application very easily.”
    Dim msg As New Net.Mail.MailMessage(sFrom, sTo, sSubject, sBody)
    Dim client As New Net.Mail.SmtpClient(“”, 25)
    Dim SMTPUserInfo As New System.Net.NetworkCredential(““, “password”)
    client.UseDefaultCredentials = False
    client.Credentials = SMTPUserInfo