How to send email in ASP.NET with SMTP authentication

Basic example of sending mail using System.Net.Mail in C#.  Settings that require updating highlighted in red.

<%@ Import Namespace="System.Net" %>
<%@ Import Namespace="System.Net.Mail" %>

<script language="C#" runat="server">
  protected void Page_Load(object sender, EventArgs e)
  {
    MailMessage mail = new MailMessage();

    mail.From = new MailAddress("[email protected]");
    mail.To.Add("[email protected]");

    mail.Subject = "Test email sent from System.Net.Mail";
    mail.Body = "Mail test";
    mail.Headers.Add("Message-Id",
                      String.Format("<{0}@{1}>",
                      Guid.NewGuid().ToString(),
                      "domain.com"));

    SmtpClient smtp = new SmtpClient("sm##.internetmailserver.net");

    NetworkCredential Credentials = new NetworkCredential("[email protected]", "password");
    smtp.Credentials = Credentials;
    smtp.EnableSsl = true;
    smtp.Send(mail);
    lblMessage.Text = "Mail Sent";
  }
</script>
<html>
<body>
  <form runat="server">
    <asp:Label id="lblMessage" runat="server"></asp:Label>
  </form>
</body>
</html>