Sending SMTP Email

Hello, I do not have access to the SMTP server on my dev machine and I would like to test my code. I was told that I would be able to send the email to a specified file in a specified explorer folder instead of trying to send to the SMTP server to send it normal email. Was the information given to me true? If I was told correctly then I am confused. I know my code would send an email because it is trying to connect to the server that it does not have access too thus timing out. Its a process to push code to the actual server that contains the smtp server and I was hoping that I could use the file process to see the results of what would normally sent out in an email. If this can be done could someone supply some sample code to help me understand. Thanks

Hi @NasaGuy
Try this code:

            SmtpClient sClient = new SmtpClient();
            sClient.DeliveryMethod = SmtpDeliveryMethod.SpecifiedPickupDirectory;
            sClient.PickupDirectoryLocation = @"d:\test\";
            MailMessage msg = new MailMessage("from@aaa.com", "to@bbb.com", "subject", "body");
            sClient.Send(msg);

You should then be able to find your message in the d:\test\ folder. Note: the file name is automatically generated as Guid and has the extension .eml.

Thank you very much Alexander that is exactly what I needed!

@NasaGuy,

Thank you very much for your feedback.

If you have any other questions, please, feel free to ask.