- Magic Strings and Magic Numbers
- String and StringBuilder
- NUnit & Visual Studio
- Value Type vs Reference Type
- Raking Leaves and Writing Code
- C# Properties Get and Set
- ASP.NET Server Performance Testing
- CSS Animation Resources
- NUnit, Unity Dependency Injection, MOQ and Private Fields
- Technical Debt Is Inevitable
- How Does The Internet Work?
- Selenium Performance Improvements
- WebForms vs MVC–The War Is Over
- My Visual Studio Toolbox
- What’s In My Blogging Toolbox?
Friday Books - Silverlight 2 in Action
jQuery - Explaining Last Week's Code
How Does The Internet Work?
SQL CURSOR Performance - SQL For Programmers
Do you write quality programs? Really?
Social Sites Are Dead?
using - There's more there than you are using
Unrecognized Tag Prefix or Device Filter ‘asp’
DotNetNuke Modules - Benefits of Architecture
Converting a DataList to a ListView
Test Sending Email without a Server in ASP.NET
You can also get the feed via email. Sign up now by supplying your email address and clicking the Subscribe button
By now, most people are familiar with the fact that ASP.NET will send mail from the codebehind by simply adding a few lines to your web.config file and adding another few lines of code in the codebehind file.
But it wasn’t until recently that I found that you don’t need to have access to an SMTP server to test your code.
In fact, this little trick will allow you to read the email without clogging up your email client with email you only wanted for testing purposes.
Instead of the normal entry of
<mailSettings> <smtp from="firstname.lastname@example.org"> <network host="maiServerl" password="password" userName="loginName" port="25"/> </smtp> </mailSettings>
You can use
<mailSettings> <smtp from="email@example.com" deliveryMethod="SpecifiedPickupDirectory"> <specifiedPickupDirectory pickupDirectoryLocation="c:\mail"/> </smtp> </mailSettings>
This will drop your email message in the c:\mail directory as an *.eml file which you can open with Outlook Express.
The code you would write to send the mail is still the same:
SmtpClient smtp = new SmtpClient(); MailAddress from = new MailAddress(fromEmail, fromEmail); MailAddress to = new MailAddress(emailAddress, emailAddress); MailMessage message = new MailMessage(from, to); message.Subject = SubjectLine; message.Body = htmlString; message.From = from; message.To.Add(to); message.IsBodyHtml = true; smtp.Send(message);
Like this Article? Subscribe to get every article sent to your email.
- Templated E-Mail using .NET One thing I’m pretty consistent about is letting the computer do most of my work for me. As a “programmer” I really don’t like to program. I prefer to solve problems. You’ve […]
- Find and report unhandled exceptions OK.. I don't have time to try this right now. But, if this works even a little bit, it is probably worth the $300 they want for it.Find and report unhandled exceptions - Exception […]
- Managing Email I recently started using a product called Clear Context that does a much better job of integrating Outlook's email with Outlook's calendar. The two things I like best about it are that it […]
- Determine The Role of a User in ASP.NET There are several controls that allow you to display content based on the role a user is in, including: - LoginView - LoginStatus And the web.config file allows us to control which […]
- ASP.NET Session Variables Not Sticking I’ve stumbled across this problem twice in the last couple of months so I figure it is about time I blogged about it. The situation is that you have a page on your web site that […]
- 18 August 2009 at 8:08am
- Dew Drop – August 18, 2009 | Alvin Ashcraft's Morning Dew
[...] Test Sending Email without a Server in ASP.NET (Dave M. Bush) ...