DZone
Thanks for visiting DZone today,
Edit Profile
  • Manage Email Subscriptions
  • How to Post to DZone
  • Article Submission Guidelines
Sign Out View Profile
  • Post an Article
  • Manage My Drafts
Over 2 million developers have joined DZone.
Log In / Join
Refcards Trend Reports
Events Video Library
Over 2 million developers have joined DZone. Join Today! Thanks for visiting DZone today,
Edit Profile Manage Email Subscriptions Moderation Admin Console How to Post to DZone Article Submission Guidelines
View Profile
Sign Out
Refcards
Trend Reports
Events
View Events Video Library
Zones
Culture and Methodologies Agile Career Development Methodologies Team Management
Data Engineering AI/ML Big Data Data Databases IoT
Software Design and Architecture Cloud Architecture Containers Integration Microservices Performance Security
Coding Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks
Culture and Methodologies
Agile Career Development Methodologies Team Management
Data Engineering
AI/ML Big Data Data Databases IoT
Software Design and Architecture
Cloud Architecture Containers Integration Microservices Performance Security
Coding
Frameworks Java JavaScript Languages Tools
Testing, Deployment, and Maintenance
Deployment DevOps and CI/CD Maintenance Monitoring and Observability Testing, Tools, and Frameworks

Integrating PostgreSQL Databases with ANF: Join this workshop to learn how to create a PostgreSQL server using Instaclustr’s managed service

Mobile Database Essentials: Assess data needs, storage requirements, and more when leveraging databases for cloud and edge applications.

Monitoring and Observability for LLMs: Datadog and Google Cloud discuss how to achieve optimal AI model performance.

Automated Testing: The latest on architecture, TDD, and the benefits of AI and low-code tools.

Related

  • Migrating from Sakila-MySQL to Couchbase - Part 3: Stored Procedures
  • MDC Logging With MuleSoft Runtime 4.4
  • Generate a Dependent Drop List in a Spreadsheet Using Go Language
  • Drag and Drop Using Angular 7

Trending

  • Decoding Business Source Licensing: A New Software Licensing Model
  • How TIBCO Is Evolving Its Platform To Embrace Developers and Simplify Cloud Integration
  • Hugging Face Is the New GitHub for LLMs
  • DevSecOps: Integrating Security Into Your DevOps Workflow

Configuring SmtpClient to Drop Emails in a Folder on Disk

Mike Hadlow user avatar by
Mike Hadlow
·
Jan. 29, 10 · News
Like (0)
Save
Tweet
Share
5.99K Views

Join the DZone community and get the full member experience.

Join For Free

Did you know that you can configure the built-in System.Net.Mail.SmtpClient to drop emails into a location on disk? This means that you don’t need an SMTP server for testing the email sending capabilities of your application.

You can find this advice in numerous places on the interweb, but I need to make a note here because every time I want to do it, I can’t remember the details and have to waste time browsing for it.

Simply put this configuration section in your App.config or Web.config file:

<system.net>
<mailSettings>
<smtp deliveryMethod="SpecifiedPickupDirectory">
<specifiedPickupDirectory pickupDirectoryLocation="c:\temp\maildrop\"/>
</smtp>
</mailSettings>
</system.net>

Now when you have some code like this:

var smtpClient = new SmtpClient();

var message = new MailMessage("no-reply@suteki.co.uk", "mike@suteki.co.uk")
{
Subject = "The subject",
Body = "The body of the message"
};

smtpClient.Send(message);

You get a file deposited in C:\temp\maildrop called something like ec40a365-270f-49ac-9aa5-1e68ec6a4df1.eml that looks like this:

X-Sender: no-reply@suteki.co.uk
X-Receiver: mike@suteki.co.uk
MIME-Version: 1.0
From: no-reply@suteki.co.uk
To: mike@suteki.co.uk
Date: 27 Jan 2010 21:32:05 +0000
Subject: The subject
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: quoted-printable

The body of the message

Sweet!

 

Drops (app)

Published at DZone with permission of Mike Hadlow, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

Related

  • Migrating from Sakila-MySQL to Couchbase - Part 3: Stored Procedures
  • MDC Logging With MuleSoft Runtime 4.4
  • Generate a Dependent Drop List in a Spreadsheet Using Go Language
  • Drag and Drop Using Angular 7

Comments

Partner Resources

X

ABOUT US

  • About DZone
  • Send feedback
  • Careers
  • Sitemap

ADVERTISE

  • Advertise with DZone

CONTRIBUTE ON DZONE

  • Article Submission Guidelines
  • Become a Contributor
  • Visit the Writers' Zone

LEGAL

  • Terms of Service
  • Privacy Policy

CONTACT US

  • 3343 Perimeter Hill Drive
  • Suite 100
  • Nashville, TN 37211
  • support@dzone.com

Let's be friends: