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



My Profile

Gifts

Active Members
TodayLast 7 Days more...







Sending eMail using SmtpClient class


Posted Date: 23 Feb 2007    Resource Type: Code Snippets    Category: Email

Posted By: kumar       Member Level: Diamond
Rating:     Points: 10



This sample code demonstrates how to send an email using the System.Net.Mail.SmtpClient class.


private bool sendMail(string strToAddress, string strFromAddress, string strSubject, string strBody)
{
// new instance of MailMessage
MailMessage mailMessage = new MailMessage();

// Sender Address
mailMessage.From = new MailAddress(strFromAddress);

// Recepient Address
mailMessage.To.Add(new MailAddress(strToAddress));

// Subject
mailMessage.Subject = strSubject;

// Body
mailMessage.Body = strBody;

// format of mail message
mailMessage.IsBodyHtml = true;

// new instance of Smtpclient
SmtpClient mailSmtpClient = new SmtpClient("smtpServer");

// mail sent
mailSmtpClient.Send(mailMessage);
}




Responses

Author: gokul    12 May 2008Member Level: Bronze   Points : 2
NIce example dude


Author: santhoshkumar    12 May 2008Member Level: Gold   Points : 2
Good kumar.


Author: gokul    12 May 2008Member Level: Bronze   Points : 2
NIce example dude


Author: Pandya Markand V    16 Jul 2008Member Level: Bronze   Points : 2
i used this code, but its not working.
at the end at send(mailMessage), it shows error like
"Sending Faiure"...
i'm usnig my 2 email accounts to send n receive.

plzzz give me some suggetion, how can i send mail from my
website.

i'm making website which contains a form.
user will fill his email id in it and when he/she
click on submit, one mail should be sent to that person
on my name/id as a sender.

hoping 4 fast rly...
thanking u.
markand pandya


Author: Curve Technologies    06 Sep 2008Member Level: Bronze   Points : 2
you need to define the smtp server to send an email that can be defined in the web.config. it can be as follows:-












-----
You can also refer to a similar kind of example at the following url:- http://forums.asp.net/t/971802.aspx

Hope this helps and resolve your problem.

Thanks..


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.
Previous Resource: Send email with embedded images
Return to Discussion Resource Index
Post New Resource
Category: Email


Post resources and earn money!
 
Related Resources



dotNet Slackers   BizTalk Adaptors    Web Design

silicone halloween masks

Contact Us    Privacy Policy    Terms Of Use