Hello,

I just setup SMTP in IIS 7.5. It's configured to pickup emails in a pickup directory.

Now I'm trying to get my application to use this service to send emails. Here is the code to send emails:

Code:
string bodyTextHtml = "..."

MailMessage mailMessage = new MailMessage
{
From = new MailAddress("promcom@riskalive.com"),
Subject = "New File Upload from www.riskalive.com",
Body = bodyTextHtml,
IsBodyHtml = true
};

string to = "gshah@acm.ca";
string smptServer = "localhost";
string username = [username I setup in IIS]
string password = [password I setup in IIS]
int smtpPort = 25

try
{
SmtpClient smtpClient = new SmtpClient(smptServer)
{
Port = smtpPortInt,
Credentials = new NetworkCredential(username, password),
DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory,
PickupDirectoryLocation = @"C:\inetpub\wwwroot\RiskAliveAPI\SMTPPickups",
EnableSsl = false
};

smtpClient.Send(mailMessage);
}
catch (SmtpException e)
{
Logger.Log("SendEmailNotification(): exception: " + e.Message);
if (e.InnerException != null)
{
Logger.Log("SendEmailNotification(): inner exception: " + e.InnerException.Message);
}

throw e;
}
I've also got this in my web.config:

Code:
<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="C:\inetpub\wwwroot\RiskAliveAPI\SMTPPickups" />
<network defaultCredentials="false" />
</smtp>
</mailSettings>
</system.net>
I get a success message from my application saying the email was sent, but when I look in the pickup directory, I see a new .eml file just sitting there. It's been sitting there for hours and I'm not getting an email.

The SMTP service is running (I had to go into IIS 6 to enable it, don't know why) and I've opened port 25 on my firewall.

One thing to note is that the application is running on a virtual server (Windows Server 2008 R2). The physical machine is an AWS server. I've got port 25 open on that too.

Does the SMTP service have to be setup to periodically check the pickup directory? Why else might emails just sit there?

Thank you.