Qus:    Write code to send e-mail from an ASP.NET application.
Nov 18, 2020 11:30 2 Answers Views: 100 ALLINO

 SmtpClient smtpClient = new SmtpClient("domain.a2hosted.com", 25);



smtpClient.Credentials = new System.Net.NetworkCredential("user@example.com", "password");

smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;



MailMessage mailMessage = new MailMessage(txtFrom.Text, txtTo.Text);

mailMessage.Subject = txtSubject.Text;

mailMessage.Body = txtBody.Text;

smtpClient.Send(mailMessage);

Prev Next
Answers (2)
NAIDU Nov 20, 2020 11:10
Answer:   MailMessage mailMess = new MailMessage ();
mailMess.From = "abc@gmail.com";
mailMess.To = "xyz@gmail.com";
mailMess.Subject = "Test email";
mailMess.Body = "Hi This is a test mail.";
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send (mailMess);
MailMessage and SmtpMail are classes defined System.Web.Mail namespace..

PARTH Nov 21, 2020 01:47
Answer:   SmtpClient smtpClient = new SmtpClient("domain.a2hosted.com", 25);

smtpClient.Credentials = new System.Net.NetworkCredential("user@example.com", "password");
smtpClient.DeliveryMethod = SmtpDeliveryMethod.Network;

MailMessage mailMessage = new MailMessage(txtFrom.Text, txtTo.Text);
mailMessage.Subject = txtSubject.Text;
mailMessage.Body = txtBody.Text;
smtpClient.Send(mailMessage);

Post Your Answer
Guest User

Not sure what course is right for you?

Choose the right course for you.
Get the help of our experts and find a course that best suits your needs.


Let`s Connect