.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> C# >> Post New QuestionBookmark and Share Subscribe to Forum

How to write code for sending EMail through c#.net

Posted By: Vikramraj     Posted Date: April 29, 2010    Points:2   Category :C#
I am writting code for sending E-mail through c#.net 2010. I use Using System.Web.Mail While writting SMTP Server it gives Message like this SMTPServer is obsolete.
Plz Send me how should i solve this problem

Responses
Author: Lalij Mer             
Posted Date: April 29, 2010     Points: 5   

You will get idea pls try this links

http://support.microsoft.com/kb/310273

http://www.c-sharpcorner.com/UploadFile/dchoksi/SendingMail02132007002923AM/SendingMail.aspx

Please Check my answer if you help....
Thank You...

Lalit.
Author: Venkat             
Posted Date: April 29, 2010     Points: 5   

Hi,

Use MailMesasge class available in system.Net.Mail Namespace to send mail using C#.

protected void btnSendmail_Click(object sender, EventArgs e)
{

SmtpClient smtpClient = new SmtpClient();
MailMessage message = new MailMessage();

try
{
MailAddress fromAddress = new MailAddress(txtEmail.Text, txtName.Text);

smtpClient.Host = "localhost";

smtpClient.Port = 25; // Add port no

message.From = fromAddress;

message.To.Add("admin1@yoursite.com");
message.Subject = "Feedback";

message.CC.Add("admin1@yoursite.com");
message.CC.Add("admin2@yoursite.com");

message.Bcc.Add(new MailAddress("admin3@yoursite.com"));
message.Bcc.Add(new MailAddress("admin4@yoursite.com"));

message.IsBodyHtml = false;

message.Body = txtMessage.Text;

smtpClient.Send(message);

lblStatus.Text = "Email successfully sent.";
}
catch (Exception ex)
{
lblStatus.Text = "An exception has occurred while sending mail." + ex.Message;
}
}


ref http://www.codeproject.com/KB/aspnet/EmailApplication.

Mark As Answer if this solve your problem
Warm Regards,
Venkat
Author: Usha             
Posted Date: May 04, 2010     Points: 5   


Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend