October 6, 2022

Samir Daoudi's Technical Blog

SharePoint, Office 365, C#, .Net, SQL Server News, Tips, Ebooks, Events, Webinars ….etc

Test SMTP Server for ASP.net Dev machines

Hi Guys,

If you need to test the email sending process from your asp.net application in local dev boxes (i.e. where you can’t connect to an smtp server), don’t worry, there is a fix for this.

First we need to change the web.config file

      <smtp deliveryMethod="SpecifiedPickupDirectory">
        <specifiedPickupDirectory pickupDirectoryLocation="C:\Mails\"/>


This changes implies that all emails sent are saved in C:\Mails folder, now, in order to send your email

public static bool Send(string To, string Subject, string Message, string From)
          System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
           mailMessage.From = new MailAddress(From);
           mailMessage.Subject = Subject;
           mailMessage.Body = Message;
           SmtpClient smtpClient = new SmtpClient();// Rememer to change this ("smtp.your-isp.com");
           return true;
      catch (Exception ex)
           return false;

Leave a comment

You may have missed

Show Buttons
Hide Buttons

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

%d bloggers like this: