Send Email in SharePoint Online Using SharePoint Client Object Model (CSOM)

HI, Below i have figured how to send Email in SharePoint Online using  SharePoint Client Object Model (CSOM).

In this case i have used “Microsoft.SharePoint.Client.Utilities”

This is a commonly used method to send email. You can use a SharePoint Utility class to send an Email. One downside is that you cannot send to external users. If you are sending to external users they should be added to your mail exchange.  That needs to be done in advance since it will take some time to reflect such changes.

Below is the Simple Code,

using (var EmailclientContext = clientContext)
{
 var emailprpoperties = new EmailProperties();
emailprpoperties .BCC = new List<string> { “udara@udaradevlab.onmicrosoft.com” };
emailprpoperties .To = new List<string> { “udara@udaradevlab.onmicrosoft.com” };
emailprpoperties .From = “testuser@udaradevlab.onmicrosoft.com”;
emailprpoperties .Body = “<b>Hi Udara, You receive a test Mail</b>”;
emailprpoperties .Subject = “Mail Testing”;

Utility.SendEmail(EmailclientContext , emailprpoperties );
EmailclientContext .ExecuteQuery();
}

 

Thanks,

Udara

Enable Custom Scripts on SharePoint Online (O365)

Custom Scripts are disabled on SharePoint online by default. if we need to add some custom scripts or need to access your SharePoint Online Site using SharePoint Designer you need to allow custom scripts.

When you are going SharePoint Admin center in Office 365 portal, you can find setting tab ,after click on that you can find custom script title. by default these features are disabled.

capture

if you need to add custom scripts or SharePoint Designer Access to the SharePoint Online Site, you should allow these two.

you can allow custom scripts by two ways.

  1. Allow by using SharePoint Admin Center (Change using by above screen), but it takes up to 24 hours to allow custom scripts on SharePoint Online Site.
  2. Allow by using SharePoint Online Management Shell, its very simple you need to run some power shell scripts.

To Allow custom scripts by using SharePoint Online Management Shell, you have to follow below steps,

  1. Download & Install SharePoint Online Management ShellClick Here to Download SharePoint Online Management Shell.
  2. Open SharePoint Online Management Shell.Connect SharePoint site by providing SharePoint Site Credentials, run below power shell script on  SharePoint Online Management Shell.

    Connect-SPOService -Url “Site Url” -credential “User Name”

    Use SharePoint Admin Center Url for Connect SharePoint Online (eg. https://udara-admin.sharepoint.com).

  3. Allow custom scripts by using below power shell script, run this,use
    Set-SPOsite “Site Url” -DenyAddAndCustomizePages 0

After successfully run above Scripts now you can add custom scripts on SharePoint Online Site.

Hope you Learned Something,
Thanks,
Udara Eshan.

Clear SharePoint Designer Cache

Sometimes SharePoint Designer 2013 gets confused and Not Respond. One way to get it back on track is to reset it’s cache. Here is how,

Steps:

  1. Close SharePoint Designer.
  2. Delete all at    :  %USERPROFILE%\AppData\Local\Microsoft\WebsiteCache
  3. Delete all at     : %APPDATA%\Microsoft\Web Server Extensions\Cache
  4. Go to SharePoint Designer options –> General –> Application Options –> Uncheck the “Cache site data across SharePoint Designer sessions”