In ASP.NET Unleashed book (SAMS Publishing, http://www.informit.com/store/asp.net-4-unleashed-9780672331121 ISBN-10: 0-13-256581-1 ) have a snippet: File: SendMail.aspx:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Net.Mail" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script runat="server">
void Page_Load()
{
SmtpClient client = new SmtpClient();
client.Host = "localhost";
client.Port = 25;
client.Send("nate@somewhere", "[email protected]",
"Beware!", "Watch out for zombies!");
}
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>Send Mail</title>
</head>
<body>
<form id="form1" runat="server">
<div>
Email sent!
</div>
</form>
</body>
</html>
The book warning: "...sends the email by using the local SMTP Server. If your SMTP Server is not enabled, you receive the error An Existing Connection Was Forcibly Closed by the Remote Host. You can enable your local SMTP Server by opening Internet Information Services, right-clicking Default SMTP Virtual Server, and selecting Start."
By using Visual Sutio 2012, include built-in IIS Express, I can not practice this code, because IIS Express don't support SMTP.
Please help me change IIS Express to full function IIS to practice below snippet.
OK. So you installed IIS after .Net, so make sure that you've run aspnet_regiis.exe.
Now, right click your project, choose properties and follow these instructions from Microsoft.