C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Reviews   Communities   Interview   Jobs   Projects   Training   Your Ad Here    
Silverlight Games | Mentor | Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Bookmarks | Polls | Revenue Sharing | Lobby | Gift Shop |


Prizes & Awards
My Profile



Active Members
TodayLast 7 Days more...






Resources » Articles » Visual Studio »

SendMail method (using Charp)


Posted Date: 29 Aug 2009    Resource Type: Articles    Category: Visual Studio
Author: VeerabaguMember Level: Gold    
Rating: 1 out of 5Points: 6



SendMail method (using Charp)



The following function send mail to particular mail ID just check it out the following code:


public static void SendMail(string from, string to, string subject, string body, Stream attachment)
{
MailMessage mailMsg = new MailMessage();
mailMsg.From = new MailAddress(from);
mailMsg.To.Add(to);
mailMsg.Subject = subject;
mailMsg.IsBodyHtml = true;
mailMsg.BodyEncoding = Encoding.UTF8;
mailMsg.Body = body;
mailMsg.Priority = MailPriority.Normal;

//Message attachment
if (attachment != null)
mailMsg.Attachments.Add(new Attachment(attachment, "veera.text"));

// Smtp configuration
SmtpClient client = new SmtpClient();
client.Credentials = new NetworkCredential("", "");
client.Port = 25;
client.Host = "localhost";
client.EnableSsl = false;

MailMessage message = mailMsg;

client.Send(message);

}



Responses

Author: Mohan    03 Sep 2009Member Level: Diamond   Points : 0
What is MailMessage??
I Need to Add any Namespace for this??



Author: Ramesh Sahu    03 Sep 2009Member Level: Gold   Points : 1
Hi, U schould show Imports System.Net.Mail
and Setting in Web Config how to call SMTP services


Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
SendMail method (using Charp)  .  

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: Working with DataGridViewComboboxColumn
Previous Resource: Debugging Shortcut in visual studio 2005
Return to Discussion Resource Index
Post New Resource
Category: Visual Studio


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use