Click here to Skip to main content
15,940,430 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to Send email with asp.net by using smtp server....? pleasae anyone can help me its urgent
Posted

Add namespace
C#
using System.Net.Mail;

code:
C#
MailMessage myMail = new MailMessage();
                        SmtpClient smtpclient = new SmtpClient();
                        MailAddress fromadrress = new MailAddress("from mail address");            
                        myMail.From = fromadrress;
                        myMail.Subject = "Your subject";
                        myMail.Body = "Your email Body content";
                        myMail.To.Add("To email address");
                        myMail.Attachments.Add("File path");
                        smtpclient.Host = "smtp.gmail.com";
                        smtpclient.Port = 587;
                        smtpclient.EnableSsl = true;
                        smtpclient.Credentials = new system.Net.NetworkCredential("UserId","Password");
                        smtpclient.Send(myMail);

I hope it will helps you.
 
Share this answer
 
v2
Code below is for sending Email.
C#
string email = "email@email.com";
MailMessage ml = new MailMessage();
ml.From = new MailAddress("from@email.com");

ml.To.Add(new MailAddress(email));
ml.Subject = "Subject of email";
ml.Body = "Body of email";
ml.Priority = MailPriority.High;
ml.IsBodyHtml = false;
SmtpClient smtpClnt = new SmtpClient();
smtpClnt.Host = "SMTP Address";
smtpClnt.Send(ml);
 
Share this answer
 
v3

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900