Asked by:
Sending Mail to group of email addresses at once

Question
-
Hello there,
I have a contact entity that has multiple email fields (Max 5).
My scenario is to send email to all those emails associated with the record at once.
For example:-
if a Contact named "XYZ" has 5 emails and if i send email to "XYZ" , the emails must be sent to all his email addresses.
may i know how this could be achieved? and the methods? :)
Instructions | Links | Etc would be helpful
Thanks once again :)
Tuesday, November 11, 2014 4:44 AM
All replies
-
Hi,
Write a plugin which fires on create of email. Before sending an email, Retrieve all the emails of contact and add them to addressused with ; seperated.
If it did not work, Add them to partylist. It should work
Thanks,
Sreeni Pavalla
- Edited by Sreenivasulu Pavalla CRM Tuesday, November 11, 2014 5:22 AM
Tuesday, November 11, 2014 5:20 AM -
Write a plugin which fires on create of email. Before sending an email, Retrieve all the emails of contact and add them to addressused with ; seperated.
Hello Sreenivasulu
Could you provide me a basic idea ? :)
I have like 5 fields in Contact form = Email,Email1,Email2,Email3,Email4
Email1-4 are custom fields. i want like when i select the record and choose "send direct email" option , the mail needs to be sent to all the email addresses of the particular contact record.
Tuesday, November 11, 2014 5:27 AM -
Hi,
Here is the algo. to do sooo
//tofield = Retrive To field from Email
//xyzContact = from tofield, retrive the Contact's Email1,Email2,Email3 & Email4
//Loop over "Email1,Email2,Email3 & Email4"
//Create "activityparty" object of email and assign it to "To" field of Email- Edited by Piyush Parate Tuesday, November 11, 2014 6:43 AM
Tuesday, November 11, 2014 6:42 AM -
Hi,
You can do something like this
var fields = new[] { "to", "cc", "bcc" }; try { var email = context.InputParameters["Target"] as Entity; foreach (var field in fields) { if (email != null && email.Attributes.Contains(field)) { var emailList = email.GetAttributeValue<EntityCollection>(field); foreach (Entity e in emailList.Entities) { string[] entityDetails = GetEntityDetails(e, service); if(entityDetails[0] != string.Empty) { e.Attributes["addressused"] = entityDetails[0]; } if (entityDetails[1] != string.Empty) { e.Attributes["partyidname"] = entityDetails[1]; } } } } }
specify your email id and create few more objects to TO and send it.
Lemme know if you still need assitnace.
Sreeni Pavalla
Tuesday, November 11, 2014 10:15 AM -
Hi,
You can do something like this
var fields = new[] { "to", "cc", "bcc" }; try { var email = context.InputParameters["Target"] as Entity; foreach (var field in fields) { if (email != null && email.Attributes.Contains(field)) { var emailList = email.GetAttributeValue<EntityCollection>(field); foreach (Entity e in emailList.Entities) { string[] entityDetails = GetEntityDetails(e, service); if(entityDetails[0] != string.Empty) { e.Attributes["addressused"] = entityDetails[0]; } if (entityDetails[1] != string.Empty) { e.Attributes["partyidname"] = entityDetails[1]; } } } } }
specify your email id and create few more objects to TO and send it.
Lemme know if you still need assitnace.
Hi Sreeni,
Very nice of you to help me . :)
I pretty much got lost by seeing the above code. "P.S: I am still a newbie :)"
Could you please explain me in an easy way :(? Some people said that this could be achieved using Custom Workflow but i dont know how .
Thanks :)
Thursday, November 13, 2014 7:47 AM -
Hi Sreekanth,
U can achieve this using plugin or custom workflow.
Follow the below link which explains how to send mail through plugin.
http://msdn.microsoft.com/en-us/library/hh210217.aspx
In the above blog you wont require the CreateRequiredRecords() and DeleteRequiredRecords() methods.
Rather you can get all your email field values using the code as suggested by Sreeni and set the TO, CC, BCC fileds in the newly created SendEmail object to send the mail.Hope this gives you a better idea. Let me know if you are facing any issues creating the plugin.
Thanks,
Prasad.
Friday, November 14, 2014 10:21 AM