Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Send email using CSOM to authenticated external users in SharePoint Online
using Microsoft.SharePoint.Client;
using Microsoft.SharePoint.Client.Utilities;
using System;
using System.Security;
namespace ExternalUsersEmail
class Program
static void Main(string[] args)
//Authenticated ClientContext. I am using SharePointOnlineCredentials but YMMV.
var clientContext = GetClientContext();
var web = clientContext.Web;
//Full logon name of the authenticated external user you want to send the email to.
var emailProperties = new EmailProperties();
//Email of authenticated external user
emailProperties.To = new string[] { "" };
emailProperties.Body = "This is the email body";
emailProperties.Subject = "This is the email subject";
Utility.SendEmail(clientContext, emailProperties);
private static ClientContext GetClientContext()
string siteUrl = "";
var clientContext = new ClientContext(siteUrl);
string passwordPlainText = "userpassword";
string currentUserLoginName = "";
var passWord = new SecureString();
foreach (char c in passwordPlainText.ToCharArray()) passWord.AppendChar(c);
clientContext.Credentials = new SharePointOnlineCredentials(currentUserLoginName, passWord);
return clientContext;

This comment has been minimized.

Copy link

@sandippal972258 sandippal972258 commented Jan 18, 2020

Its not working in my case, I can send email from outlook but Programmatically , i can't send EMAIL. Is there any specific licence needed for send email.?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment