- LinkedIn Tips For Programmers
- Debugging Software
- Why Is It Called “Inversion of Control”?
- SpecFlow Tutorial
- The Parable of The Road Line Painter
- Setting up SpecFlow
- Code Comments & Agile Programming
- Cracking the Programmer’s Interview Code
- Run NUnit from Visual Studio
- TDD Gamification – Turning Test Driven Development into a Game
- How to Become a Better Programmer
- Limiting Beliefs of Programmers
- Node.js Tools For Visual Studio
- 100% Code Coverage Possible?
DotNetNuke Modules - Data Access Layer
CSS Animation Resources
OOP is not the main problem w/ ASP.NET
Using StoredProcedures with LINQ 2 SQL Classes
DotNetNuke CSS in your Module Settings
Swapping Out the DAL
Multi-Step Processing in ASP.NET
Simple Properties in C# 3.5
CSharp ?? Operator
Selenium Performance Improvements
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 […]
- 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 […]
- Cross Language References in ASP.NET Most ASP.NET programmers are aware that the environment allows programmers to write code in multiple languages. This is what allows a programmer who prefers CSharp to write modules […]
- 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) ...