It’s a very common requirement to send email through custom code when we design and develop an application. In general for custom web part in SharePoint 2013, we can use internal organization SMTP address to send email notification through code. In Azure hosted solution in SharePoint online (Download PDF for FREE), we have to follow below approach to send Email. We will need a cloud only account created in Office 365 Online Exchange without Multifactor authentication enabled.
The account will be used in the Azure app to send email to connect directly to Office 365 using the SMTP client submission endpoint “smtp.office365.com” and establish the connection.
We will have to use the Cloud Only account and password provided in a code to connect “smtp.office365.com”
Below code snippet for further reference.
SmtpClient clt = new SmtpClient();
clt.UseDefaultCredentials = false;
clt.Credentials = new System.Net.NetworkCredential(“O365 cloud only user account”, “Password”);
clt.Port = 587;
clt.Host = “smtp.office365.com”;
clt.DeliveryMethod = SmtpDeliveryMethod.Network;
clt.EnableSsl = true;
Hope this will be helpful.
Download FREE SharePoint 2019 Installation PDF Guide
This FREE PDF contains, Steps by step guide to install SharePoint 2019 Preview, prerequisites, hardware and software new features. First impression to SharePoint Server 2019 new modern site, modern lists and modern document libraries.
You May Also like the Following SharePoint Online Tutorials: