How to Send email via SharePoint Context,
Get User Name, Password, Hub Manager email, User email, From an email from Config as per your requirements.
try
{
SecureString secPwd = new SecureString();
foreach (var p in password)
{
secPwd.AppendChar(p);
}
secPwd.MakeReadOnly();
using (var clientContext = new ClientContext("https://{Tenant}.sharepoint.com"))
{
clientContext.Credentials = new SharePointOnlineCredentials(userName, secPwd);
var emailp = new EmailProperties();
emailp.BCC = new List<string> { user.Email };
emailp.To = new List<string> { hubManagersEmail };
emailp.From = userName;
emailp.Body = "<b>Hi Moderators, <p>Please review the the Page data as tool found blocked words in page</p><p>Regards,</p><p>Admin Team</p></b>";
emailp.Subject = "Profanity Alert! ! Found blocked words in page";
Utility.SendEmail(clientContext, emailp);
clientContext.ExecuteQuery();
log.Info("Sent Email on Blocked words");
}
}
catch (Exception)
{
log.Info("Error while Sending email");
}
OUTPUT EMAIL LOOKS AS BELOW:
No comments:
Post a Comment