1. Server manager, go to features, select "add features", select "smtp server"
2. Internet Information Services (IIS) 6.0 Manager, make sure that SMTP virtual server/default smtp server is running
3. Download and install the metabase explorer tool (part of the Internet Information Services (IIS) 6.0 Resource Kit Tools)
4. Metabase Explorer, give / check read permissions to IIS_IUSRS group on the LM/SMTPSvc/1, LM/SMTPSvc and LM
5. Give IIS_IUSRS group write permissions to pickup folder (C:\inetpub\mailroot\Pickup)
6. Use the following asp.net configuration settings:
<?xml version="1.0" encoding="UTF-8"?>
<configuration xmlns="http://schemas.microsoft.com/.NetConfiguration/v2.0">
<system.net>
<mailSettings>
<smtp deliveryMethod="PickupDirectoryFromIis" from="website@contoso.com" />
</mailSettings>
</system.net>
</configuration>
7. Test aspx page
<%@ page language="C#" autoeventwireup="false" inherits="System.Web.UI.Page" title="Test Email" %>
<%@ import namespace="System.Net" %>
<%@ import namespace="System.Net.Mail" %>
<script runat="server">
protected void bTestMail_Click(object sender, EventArgs e)
{
string time = DateTime.Now.ToString();
MailMessage mm = new MailMessage();
mm.From = new MailAddress(tbFrom.Text);
mm.To.Add(tbTo.Text);
mm.Subject = "Test email (" + time + ")";
mm.Body = "Test SmtpDeliveryMethod.PickupDirectoryFromIis";
try
{
SmtpClient smtp = new SmtpClient();
smtp.DeliveryMethod = SmtpDeliveryMethod.PickupDirectoryFromIis;
smtp.Send(mm);
Response.Write("Message send (" + time + ")");
}
catch (SmtpException ex)
{
Response.Write(ex.Message);
}
}
</script>
<html>
<head>
<title>Test SmtpDeliveryMethod.PickupDirectoryFromIis</title>
</head>
<body>
<form runat="server">
From:<asp:textbox id="tbFrom" runat="server"></asp:textbox><br/>
To:<asp:textbox id="tbTo" runat="server"></asp:textbox><br/>
<asp:button runat="server" text="Send" onclick="bTestMail_Click" />
</div>
</form>
</body>
</html>
Sources:
http://forums.iis.net/p/1157046/1901343.aspx
http://stackoverflow.com/questions/1615088/problem-with-smtp-in-iis7