Need code for a program which sends mails.

Posted by Udaysimha under ASP.NET on 2/25/2012 | Points: 10 | Views : 658 | Status : [Member] | Replies : 2
Hi All,

Please let me help to get sample code for mail sending in asp.net.

Thanks
Uday

uday


Responses

Posted by: Ppathi on: 2/25/2012 [Member] Starter | Points: 25

Up
0
Down
Hi,

Add this name space

using System.Web.Mail;

MailSub = "YOUR OWN SUBJECT";
MailBody = "YOUR OWN CONTENT";
MailMessage Mail1 = new MailMessage();
Mail1.BodyFormat = MailFormat.Html;
Mail1.From = "test@test.com";
Mail1.To = "Client Email ID";
Mail1.Subject = MailSub;
Mail1.Body = MailBody;
SmtpMail.SmtpServer = "YOUR SMTP MAIL IP";
SmtpMail.Send(Mail1);

Thanks & Regards,
Pasupathi G
No Pain No Gain

Udaysimha, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sksamantaray on: 2/25/2012 [Member] Silver | Points: 25

Up
0
Down
Can try this also

  


using System.Net.Mail;
//btnSubmit
SmtpClient smtpClient = new SmtpClient("127.0.0.1");

smtpClient.Port = 25;
MailMessage message = new MailMessage("sanjayasamantaray@gmail.com", "sanjayasamantaray@gmail.com");
message.Subject = "<h1>From US server</h1>";
message.Body = "From US Server 3";
message.IsBodyHtml = true;
smtpClient.Send(message);


Thanks,
Sanjay

Udaysimha, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response