Qus:    How do I set up an email server in ASP.NET using C#?
Feb 27, 2021 09:10 2 Answers Views: 662 SWEETY
Prev Next
Answers (2)
PARTH Mar 01, 2021 01:43
Answer:   1. Create instances of the SmtpClient and MailMessage classes.
2. Set the properties for the SmtpClient and MailMessage instances (such as the mail server, sender address, recipient address, message subject, and so on).
3. Call the Send() method of the SmtpClient instance to send the message.

FRAUSKY Mar 01, 2021 09:07
Answer:   Make the use of SMTP (Simple Mail Transfer Protocol) which is used to send and receive emails from one server to another or across people.
Example –
using System.IO;
using System.Net;
using System.Net.Mail;

public class SendEmail
public void Email()
string to = "toaddress@gmail.com"; //To address
string from = "fromaddress@gmail.com"; //From address
MailMessage message = new MailMessage(from, to);

message.Subject = "Sending Email";
message.Body = "Sample Email";
message.BodyEncoding = Encoding.UTF8;
message.IsBodyHtml = true;
SmtpClient client = new SmtpClient("smtp.gmail.com", 587); //Gmail SMTP
System.Net.NetworkCredential basicCredential1 = new
System.Net.NetworkCredential("yourmail id", "Password");
client.EnableSsl = true;
client.UseDefaultCredentials = false;
client.Credentials = basicCredential1;
catch (Exception ex)
throw ex;

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