1
votes

I'm writing plugin C#, to send an email to the users who are under SystemCustomizer role notifying that Contact is creating or Updating.

How to send an email to multiple users (Bulkmailing/ forEach loop for creating mail request to every user)?

1
What have you tried, blocked with some issue? - Arun Vinoth - MVP
thank you @Arun.. I am trying to send a mail to multiple users everytime when the contact record is being updated or created. We know we can do from plugin. But the thing is I want to send at a time like bulksending.. can we do that..? - NaveenGNK
This is unclear. 1. Do you want to send for each contact create/update to all Sys customizers? 2. Or contact create/update summary everyday to SCs? 3. Do you want single email & all of them on To/Cc or individual email to each SC? - Arun Vinoth - MVP
I'm not the guy that downvoted you, but here's why you were downvoted. Stack Overflow is a place for resolving particular, specific issues with software. You're expected to lay out what your problem is, including what you've tried and what error message your'e getting. It is not a place for "I don't know anything about this software, can someone give me teh codes?" - Michael Blackburn

1 Answers

2
votes

Use a query to find each system user entity with the system customiser role.

Then for each user send an email. 1; create the email, 2; send the email.

// Create an e-mail message.
Email email = new Email
{
    To = new ActivityParty[] { toParty },
    From = new ActivityParty[] { fromParty },
    Subject = "SDK Sample e-mail",
    Description = "SDK Sample for SendEmail Message.",
    DirectionCode = true
};
_emailId = _serviceProxy.Create(email);

// Use the SendEmail message to send an e-mail message.
SendEmailRequest sendEmailreq = new SendEmailRequest
{
    EmailId = _emailId,
    TrackingToken = "",
    IssueSend = true
};

SendEmailResponse sendEmailresp = (SendEmailResponse)_serviceProxy.Execute(sendEmailreq);