Send an email with your domain credential of outlook: With the following details:
POP Settings Server: outlook.office365.com Port: 995 Encryption: SSL/TLS
SMTP Settings Server: smtp.office365.com Port: 587 Encryption: STARTTLS
How to create an email service with the exchange in .net core.
MailMessage mailMessage = new MailMessage(_options.Value.Mailbox, receiverEmail, subject, emailBody);
mailMessage.IsBodyHtml = true;
mailMessage.BodyEncoding = UTF8Encoding.UTF8;
mailMessage.CC.Add(_options.Value.Mailbox);
// SmtpClient client = new SmtpClient("smtp.office365.com", 587);
SmtpClient client = new SmtpClient(_options.Value.Server, _options.Value.Port);
client.EnableSsl = true;
client.Timeout = 100000;
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.UseDefaultCredentials = false;
//client.Credentials = new NetworkCredential(senderEmail, senderPassword);
client.Credentials = new NetworkCredential(_options.Value.Email, _options.Value.Password,
_options.Value.Server);
//MailMessage mailMessage = new MailMessage(senderEmail, receiverEmail, subject, emailBody);
await client.SendMailAsync(mailMessage);
return true;
I need to send emails using an exchange server.