Focus on Microsoft Technologies - Tutorials, Articles, Code Samples.

Thursday, August 03, 2006

Sending Email using ASP.NET, C#, VB.NET, IIS, SMTP Server, POP3

Sending Email using ASP.NET, C#

    Something found on every web page today is an email form of some sort. In all probability this will not change anytime soon, therefore I will demonstrate today how to send email via ASP.NET: from plain to HTML mail and attachments.

    The use of the source code in this article requires an installation of Microsoft's .NET Framework SDK on a Web server. I also assume a certain familiarity of the reader with the C# programming language.

The quickest way
There always is a way that can be classified under the heading 'Quick and Dirty'. And I again want to begin with this way because we can test the server configuration quite easily without having to take any side effects into consideration (SimpleMail.aspx).

<% @Page Language="C#" %>
<% @Import Namespace="System.Web.Mail" %>
  string strTo = "christophw@sleeper.Dev.AlfaSierraPapa.Com";
  string strFrom = "";
  string strSubject = "Hi Chris";SmtpMail.Send(strFrom, strTo, strSubject, "A real nice body text here");
  Response.Write("Email was queued to disk");

ToDetail Information with examples how to send mails and mails with attachements in Click Here

Tags: , , , , , , , , ,

Post a Comment

Anonymous said...

Thanks for the post, very useful.

-- Ramsome