web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Send email to secondary email contact CRM 2013

(0) ShareShare
ReportReport
Posted on by

Hi,

When a contact has two email addresses (primary and secondary).  I would like to be able to select the secondary email contact when sending an email from within CRM.  currently i am having to delete the primary address in the To field and replace with the secondary email contact.

Is there away with a drop down for example to select which email contact to send the email too.

Thanks

Mo

*This post is locked for comments

I have the same question (0)
  • RakeshJ Profile Picture
    on at

    Hello gomo1974,

    CRM for any entity by default uses value present in the Email field with schema emailaddress1 in contact entity.

    There are two other email address fields you can use to add alternate email addresses, however the emails will process using the values present in email address1 field only and after it is approved.

    I believe we will not able to achieve the scenario to select the secondary email address using recommended way as only one email address present in email address1 gets approved.

    Do let me know if that was helpful.

    Regards

    Rakesh J

    Microsoft Dynamics CRM Support !

  • Community Member Profile Picture
    on at

    Hi Rakesh,

    So what can I do if I want to use both the primary and secondary email contacts when composing a new email in CRM.  There must be a way to customise CRM to offer the secondary email contact as an option.

    Thanks

    Mo

  • Community Member Profile Picture
    on at

    Hello Gomo,

    The feature can be achieved by SDK.

    Regards,

    Dinesh 

    Microsoft Dynamicsâ„¢ CRM Support Engineer

    "Please mark my answer as verified if you found it helpful"

  • Community Member Profile Picture
    on at

    Hi,

    Thanks for your reply, it doesn't really help.  Have you come across any code that might help me to customise.

    Mo

  • Community Member Profile Picture
    on at

    Hi,

    I have the same problem and this was what i found:

    crmtipsbyprm.wordpress.com/.../send-email-to-seconday-email-of-account-and-contacts-dynamics-crm

    I have not test it yet but seems legit.

    //Martin

  • Suggested answer
    Behnam Profile Picture
    15 on at

    Hi,

    I think some coding is needed to do this as a custom workflow or a plugin fired on email creation.

    Once I had similar requirement and  I created a custom workflow which receives email as an input parameter and looks into the recipients listed in "To" field and if any of recipients (Contact recipient) has secondary email address,the same contact will receive the email as well in his secondary email . Please note in  my system workflow, I created an email record , gave it to the below custom workflow to manipulate it as above and then change the status of email as "Pending Send" to get sent out. I think it is better than a plugin to hijack every email which is being sent out because it can put a big load on the server. Code for custom workflow is as below and I removed additional statements for error handling and tracing for simplicity:

    Code : 

            /// <summary>
            /// Input parameter: Email
            /// </summary>
            [Input("Email")]
            [RequiredArgument]
            [ReferenceTarget("email")]
            public InArgument<EntityReference> Email { get; set; }
    
            //name of your custom workflow activity for tracing/error logging
            private const string ActivityName = "CC Email To Secondary Email Address";
    
            #region CodeActivity
    
            /// <summary>
            /// Executes the workflow activity.
            /// </summary>
            /// <param name="executionContext">The execution context.</param>
            protected override void Execute(CodeActivityContext executionContext)
            {
    
    
    
                if (tracingService == null)
                {
                    throw new InvalidPluginExecutionException("Failed to retrieve tracing service.");
                }
    
    
                // Create the context
                var context = executionContext.GetExtension<IWorkflowContext>();
    
                if (context == null)
                {
                    throw new InvalidPluginExecutionException("Failed to retrieve workflow context.");
                }
    
    
    
                var serviceFactory = executionContext.GetExtension<IOrganizationServiceFactory>();
                var service = serviceFactory.CreateOrganizationService(context.UserId);
    
                try
                {
    
                    var emailId = (Email.Get(executionContext)).Id;
    
          
    
                    // Retrieve the email
                    ColumnSet cols = new ColumnSet(
                         new String[] { "to", "cc" });
    
                    var email = service.Retrieve("email", emailId, new ColumnSet("to", "cc"));
    
                    EntityCollection to = email.GetAttributeValue<EntityCollection>("to");
                    EntityCollection cc = email.GetAttributeValue<EntityCollection>("cc");
    
    
                    if (to != null)
                    {
                        foreach (var party in to.Entities)
                        {
                            EntityReference partyId = party.GetAttributeValue<EntityReference>("partyid");
    
                            if (partyId.LogicalName == "contact")
                            {
                                var contact = service.Retrieve("contact", partyId.Id, new ColumnSet("emailaddress2"));
    
                                if (contact.Attributes.Contains("emailaddress2"))
                                {
    
                                    Entity alternateParty = new Entity("activityparty");
                                    alternateParty["partyid"] = new EntityReference("contact", partyId.Id);
                                    alternateParty["addressused"] = contact.Attributes["emailaddress2"];
    
    
                                    cc.Entities.Add(alternateParty);
    
                                }
    
    
                            }
    
                        }
    
                        email["cc"] = cc;
                        service.Update(email);
    
                    }
    
                }
                catch (FaultException<OrganizationServiceFault> e)
                {
                   
                }
                catch (Exception e)
                {
                   
                }
    
            }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans