Forum Discussion

MassiFE's avatar
MassiFE
Copper Contributor
Nov 07, 2024

Add button to Sharepoint list to generate an email draft with selected users' emails in bcc

I'm currently trying to replicate in Sharepoint 365, via power automate, a functionality that I had developed in a JS snippet in the old sharepoint 2013 on a Email ditribution list page.

My snippet code was this:

   <input onclick="SendMailToSelcted();" type="button" value="Send E-Mail"> 
   <br> 
   <script language="javascript" type="text/javascript">
function SendMailToSelcted() {
var items = SP.ListOperation.Selection.getSelectedItems();
var ctx = SP.ClientContext.get_current();
var web = ctx.get_web();
var currentListGUID = SP.ListOperation.Selection.getSelectedList();

var list = web.get_lists().getById(currentListGUID);

var rows = new Array();
for(var i = 0; i < items.length; i++)
{                           
  var row = list.getItemById(items[i].id);
  ctx.load(row);
  rows.push(row);
}

ctx.executeQueryAsync(function ()
{                    
 var ids = '';
 for (var i = 0; i < rows.length; i++)
 {
   var r = rows[i];
   ids += r.get_item('cs6w') + ';'  ;
 }
 document.location='mailto:' + '?bcc=' + ids ;
},

function(sender, args)
{
  alert('Request failed. \nError: ' + args.get_message() + '\nStackTrace: ' + args.get_stackTrace());
});

}
</script> 

This snippet is no more allowed in my actual SP365.

The functionality was:

once selected different users  out of the sharepoint list (with email address availble on their records), when a button at the top of the list is clicked(snippet), an outlook email draft should be created with all selected users' emails filled in "bcc" field.

The user has to edit each time that generated email draft with subject and text and send it.

I'm now not aware how to replicate it in Sharepoint 365 List through power automate and its flows.

Any suggestion is really appriciated!

Thanks Max

  • Rob_Elliott's avatar
    Rob_Elliott
    Bronze Contributor

    With Out of the box SharePoint you're not going to be able to replicate this.  The easiest solution is to use Power Apps for the user to select the recipients and to enter the subject line and the email text. Then the email can be sent directly from the app (it will go from the user).

    Rob
    Los Gallardos
    Microsoft Power Automate Community Super User.
    Principal Consultant, Power Platform and SharePoint, WSP Global (and classic 1967 Morris Traveller driver)

Resources