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 !




Emails in C#


Posted Date: 19 Aug 2008    Resource Type: Code Snippets    Category: Email

Posted By: amit chaudhary       Member Level: Silver
Rating:     Points: 10



This code will help us to send emails.
we use two namespaces for that.
System.Net.Mail and System.Net

On button click:
we first pass the reciver mail address to a string, after this we create new mail message in which the address of sender and the mail address of reciver passed.we can add cc copy to by using MailAddress copy variable.
then just add the copy and subject and revelant informations and server name and send it.

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

on button click()
{
string toaddress = "abc@xyz.com"; //write reciver mail address there
MailMessage mm = new MailMessage(TextBox2.Text, toaddress);
MailAddress copy = new MailAddress("avx@yts.com"); //write reciver mail address there
mm.CC.Add(copy);
mm.Subject = "some message: " + TextBox3.Text;
mm.Body = "Name:" + TextBox1.Text + "\r\n" + TextBox4.Text;
mm.IsBodyHtml = false;
SmtpClient smtp = new SmtpClient("server name");
smtp.Send(mm);
Label1.Text = "Thanks";
TextBox1.Text = "";
TextBox2.Text = "";
TextBox3.Text = "";
TextBox4.Text = "";
TextBox1.Focus();

}




Responses


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

Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Emails using 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: Send Exceptions or Error in Email using Log4Net
Previous Resource: Sending Email with ASP.NET
Return to Discussion Resource Index
Post New Resource
Category: Email


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

email fax service

Contact Us    Privacy Policy    Terms Of Use