SmtpClient deliveryMethod

http://bartwullems.blogspot.sg/2010/02/smtpclient-deliverymethod.html

SmtpClient deliveryMethod

One of the nice but little known possibilities of the System.Net.Mail.SmtpClient class is the ability to drop emails into a location on disk. This makes it very easy to test your code without the need of an SMTP server.

Update your app.config or web.config like this:

   1:  <system.net>
   2:    <mailSettings>
   3:      <smtp deliveryMethod="SpecifiedPickupDirectory">
   4:        <specifiedPickupDirectory pickupDirectoryLocation="c:\mails\"/>
   5:      </smtp>
   6:    </mailSettings>
   7:  </system.net>


You can also configure this setting on the class itself. Files are dropped on the specified location and can be opened using Outlook Express or Windows Mail.


发布了185 篇原创文章 · 获赞 1 · 访问量 27万+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章