Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# ASP.NET
How to Send email with asp.net by using smtp server....? pleasae anyone can help me its urgent
Posted 28-Nov-12 20:55pm
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 2

Add namespace
using System.Net.Mail;
code:
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.
  Permalink  
v2
Rate this: bad
good
Please Sign up or sign in to vote.

Solution 3

Code below is for sending Email.
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);
  Permalink  
v3

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



Advertise | Privacy | Mobile
Web01 | 2.8.141015.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100