System.net.mail

System.Net.Mail is a namespace in the.NET Framework that provides classes for sending and receiving email messages. It is part of the.NET Framework Class Library and is used to send and receive email messages using the Simple Mail Transfer Protocol (SMTP).

Here are some of the key classes and methods in the System.Net.Mail namespace:

Sending Email

Receiving Email

Email Message Properties

Email Attachment Properties

Here is an example of how to use the System.Net.Mail namespace to send an email message:

using System.Net.Mail;

// Create a new MailMessage object
MailMessage mail = new MailMessage();

// Set the sender's email address
mail.From = new MailAddress("[email protected]");

// Set the recipient's email address
mail.To.Add(new MailAddress("[email protected]"));

// Set the subject of the email message
mail.Subject = "Test Email";

// Set the body of the email message
mail.Body = "This is a test email message.";

// Create a new SmtpClient object
SmtpClient client = new SmtpClient();

// Set the SMTP server's address
client.Host = "smtp.example.com";

// Set the SMTP server's port
client.Port = 25;

// Send the email message
client.Send(mail);

Note that the System.Net.Mail namespace is part of the.NET Framework and is not available in.NET Core. In.NET Core, you can use the System.Net.Mail.SmtpClient class from the System.Net.Mail namespace, but you will need to use a third-party library such as MailKit or NReco.Mail to send and receive email messages.