I am using this to send email from contact form
- var message = new MimeMessage();
- message.From.Add(new MailboxAddress(_smtpSettings.SenderName, _smtpSettings.SenderEmail));
- message.To.Add(new MailboxAddress("[email protected]"));
- message.Subject = "Contact form communication";
- message.Body = new TextPart("html")
- {
- Text = "test message"
- };
- using (var client = new SmtpClient())
- {
- await client.ConnectAsync(_smtpSettings.Server, _smtpSettings.Port, true);
- client.AuthenticationMechanisms.Remove("XOAUTH2");
- await client.AuthenticateAsync(_smtpSettings.UserName, _smtpSettings.Password);
- await client.SendAsync(message);
- await client.DisconnectAsync(true);
- }
- Text = ContactForm.Name + ContactForm.Email + ContactForm.Company + ContactForm.Message

Sachin SinghRank #66 · 26.2K reputationPosted Mar 6, 2021, 11:39 AM EST
Marius VasileRank #785 · 2.9K reputationPosted Mar 6, 2021, 11:45 AM EST
Marius VasileRank #785 · 2.9K reputationPosted Mar 6, 2021, 11:53 AM EST
Sachin SinghRank #66 · 26.2K reputationPosted Mar 6, 2021, 12:17 PM EST
Marius VasileRank #785 · 2.9K reputationPosted Mar 6, 2021, 12:19 PM EST
Sachin SinghRank #66 · 26.2K reputationPosted Mar 6, 2021, 12:23 PM EST
Marius VasileRank #785 · 2.9K reputationPosted Mar 6, 2021, 12:24 PM EST
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questionsTop experts