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

Solution 2

Add namespace
using System.Net.Mail;

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 = "";
                        smtpclient.Port = 587;
                        smtpclient.EnableSsl = true;
                        smtpclient.Credentials = new system.Net.NetworkCredential("UserId","Password");

I hope it will helps you.
Rate this: bad
Please Sign up or sign in to vote.

Solution 3

Code below is for sending Email.
string email = "";
MailMessage ml = new MailMessage();
ml.From = new MailAddress("");
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";

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

    Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy | Mobile
Web02 | 2.8.170424.1 | Last Updated 29 Nov 2012
Copyright © CodeProject, 1999-2017
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