private void SendEmail(string toAddress)
{
try
{
string fromAddress = ""; // your gmail adress
string password = ""; // First of all, you come to gmail account management, then you open two factor authentication, then you search for application passwords, for example "pptfjitqqqtvnewof" you will create such a password, we copy it here
string toGmail = "";//recipient gmail
SmtpClient smtp = new SmtpClient
{
Host = "smtp.gmail.com",
Port = 587,
EnableSsl = true,
DeliveryMethod = SmtpDeliveryMethod.Network,
UseDefaultCredentials = false,
Credentials = new NetworkCredential(fromAddress,toGmail,password)
};
MailMessage message = new MailMessage(fromAddress, toGmail)
{
Subject = "", //you write what you want to write
Body = $": "
};
smtp.Send(message);
}
catch (Exception ex)
{
MessageBox.Show("There was an error sending an e-mail: " + ex.Message);
}
}
-
Notifications
You must be signed in to change notification settings - Fork 0
YusufMarall/Send-email
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
About
No description or website provided.
Topics
Resources
Stars
Watchers
Forks
Releases
No releases published
Packages 0
No packages published