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 » ASP.NET/Web Applications »

how to send a mail from c# application


Posted Date: 08 Sep 2008    Resource Type: Articles    Category: ASP.NET/Web Applications
Author: gopiMember Level: Silver    
Rating: 1 out of 5Points: 10



This code says " how to send a mail from your application using c# code"

add the following controls to your application

Textbox1 ( assign the name in the textbox properties like.... txtto )
Textbox2 ( assign the name in the textbox properties like..... txtsub )
Textbox3 ( assign the name in the textbox properties like..... txtmsgbody
and change the textmode as multilevel )
Button1 ( assign the name in the button properties like.... btnsend )
Label1 ( assign the name in the label properties like.... lblmsg)

c# code on button_click()
--------------



protected void btnsend_Click(object sender, EventArgs e)
{
MailMessage mm = new MailMessage();
try
{
mm.From = "gopiyadavalli@yahoo.com"; // your 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: Hitesh Kapadia    09 Sep 2008Member Level: Bronze   Points : 1
Hi gopi,
Can you explain me how and where to authenticate SMTP server?
I'm having user name and password to access mail server.
please explain.

Thanks.
Hitesh


Author: gopi    09 Sep 2008Member Level: Silver   Points : 1
HI HITESH

JUST ADD THE following namespacess...

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

then u can access the fullfledged mail


ok


have a nice programming......



Feedbacks      
Popular Tags   What are tags ?   Search Tags  
Sign In to add tags.
How to send a mail from c# application  .  

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: How to Handle MouseEvents using c# dot net
Previous Resource: Parent - Child relationship using Java Script
Return to Discussion Resource Index
Post New Resource
Category: ASP.NET/Web Applications


Post resources and earn money!
 
More Resources



dotNet Slackers

About Us    Contact Us    Privacy Policy    Terms Of Use