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 !




sending the mails from c#


Posted Date: 06 Sep 2008    Resource Type: Code Snippets    Category: Email

Posted By: gopi       Member Level: Silver
Rating:     Points: 10



Its a simple code for sending the mail from ur c# application
just add the namespacess

using System.Net;
using System.Web.Mail;

then

add the follwing ......

Button1
TextBox1 (set the name in the properties like... txtto)
TextBox2 ( set the name in the properties like.. txtsub)
Textbox3 ( set the name in the properties like .. txtmsgbody
and set the textmode as multiline)
Label1 ( set the name in the properties like .. lblmsg)

write the code

on button_click()
--------------


protected void Button1_Click(object sender, EventArgs e)
{
MailMessage mm = new MailMessage();
try
{
mm.From = "gopiyadavalli@yahoo.com"; // this is ur mail ID
mm.To =txtto .Text.ToString();


mm.Body = txtmsgbody.Text.ToString();
mm.Subject = txtsub.Text.ToString();
System.Web.Mail.SmtpMail.Send(mm);
lblmsg.Text = "Email successfully sent.";

}
catch (Exception ex)
{
lblmsg.Text = "Send Email Failed." + ex.Message;
}

}




Responses

Author: gopi    08 Sep 2008Member Level: Silver   Points : 0
gud its working

thanks for ur coding


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sending the mail from c#  .  

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: Sending Email with ASP.NET
Previous Resource: How to send Mail using VB.NET
Return to Discussion Resource Index
Post New Resource
Category: Email


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

it outsourcing

Contact Us    Privacy Policy    Terms Of Use