C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Communities   Interview   Jobs   Projects   Offshore Development    
Silverlight Tutorials | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Revenue Sharing |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...

New Feature: Community Sites: Create your own .NET community website and start earning from Google AdSense ! It's Free !






Send a mail in asp.net with c# 2.0


Posted Date: 17 Mar 2008    Resource Type: Code Snippets    Category: Email

Posted By: mukesh chauhan       Member Level: Gold
Rating:     Points: 7



Use this code to send mail through your website to others.You should have User name and password on the website from where you are going send mail. You should include System.Mail namespace.



using System.Web.Mail;


string body = "Hi this is a sample mail";



MailMessage m = new MailMessage();
m.Body = body;
m.BodyFormat = MailFormat.Html;
m.To = "abc@gmail.com";
m.From = "info@abc.com";

m.Subject = "Sample Mail";
m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/smtpauthenticate", "1");

//User name on website from where you send a mail.
m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendusername", "username" );

//Password on website from where you send a mail.
m.Fields.Add("http://schemas.microsoft.com/cdo/configuration/sendpassword","password");

SmtpMail.SmtpServer = "www.abc.com";

try
{
SmtpMail.Send(m);
Response.Write("Email has been send");
}
catch (Exception ex)
{
Response.Write(ex.Message);
}






Responses


No responses found. Be the first to respond and make money from revenue sharing program.

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
(No tags found.)

Post Feedback


This is a strictly moderated forum. Only approved messages will appear in the site. Please use 'Spell Check' in Google toolbar before you submit.
You must Sign In to post a response.
Next Resource: How to send a Mail through ASP.NET
Previous Resource: Send Emails with Gmail Account with Attachment
Return to Discussion Resource Index
Post New Resource
Category: Email


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

budget conference call

Contact Us    Privacy Policy    Terms Of Use