Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

I want to send email to the Business Unit (Email). I see that we are not able to set the partyid lookup to the Business Unit Entity. Is there any way to send email to the Business Unit entity, if i get the actual email id by querying upon the BU entity

(0) ShareShare
ReportReport
Posted on by 402

I want to send email to the Business Unit (Email). I see that we are not able to set the partyid lookup to the Business Unit Entity. Is there any way to send email to the Business Unit entity, if i get the actual email id by querying upon the BU entity.

I am writing this in a custom workflow.

*This post is locked for comments

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,076 on at
    RE: I want to send email to the Business Unit (Email). I see that we are not able to set the partyid lookup to the Business Unit Entity. Is there any way to send email to the Business Unit entity, if i get the actual email id by querying upon the BU entity

    Hi Mohammed Fakhri,

    You can send email to unresolved email addresses in Dynamics CRM by setting the configuration in System Settings.

    See: https://niravpancholi.wordpress.com/2012/05/12/c-code-for-sending-email-to-unresolved-recipients/

    Hope this helps.

  • Verified answer
    Emre GULCAN Profile Picture
    Emre GULCAN 2,379 on at
    RE: I want to send email to the Business Unit (Email). I see that we are not able to set the partyid lookup to the Business Unit Entity. Is there any way to send email to the Business Unit entity, if i get the actual email id by querying upon the BU entity

    Hi,

    You can send an email just "plain email address" by using "addressused"

    Entity from = new Entity("activityparty");
    from["partyid"] = new EntityReference("systemuser", Guid.Parse("FROM_SYSTEMUSER_ID")); // This can be also Queue
    
    EntityCollection toList = new EntityCollection();
    Entity p = new Entity("activityparty");
    p["partyid"] = new EntityReference("logicalname", Guid.Parse("id"));
                //OR 
    p["addressused"] = "simple@plainemail.com";
    
    toList.Entities.Add(p);
    
    
    Entity email = new Entity("email");
    email["subject"] = "YOUR_EMAIL_SUBJECT";
    email["description"] = "YOUR_EMAIL_BODY_CAN_BE_HTML";
    email["from"] = new[] { from };
    email["to"] = toList;
    
    Guid emailId = _organizationService.Create(email);
    
    SendEmailRequest request = new SendEmailRequest
    {
       EmailId = emailId,
       IssueSend = true,
       TrackingToken = ""
    };
    
    var response = (SendEmailResponse)_organizationService.Execute(request);

    or you can simply use XrmLibrary (Dynamics Xrm SDK helper) and send email by (blue lines are optional)

     XrmEmail xrmEmail = new XrmEmail()
    .Direction(DirectionCode.Outgoing)
    .From(XrmEmail.FromEntityType.SystemUser, Guid.Parse("FROM_SYSTEMUSER_ID"))
    .To("YOUR_BUSINESSUNIT_PLAINTEXT_EMAIL_ADDRESS")
    .To(XrmEmail.ToEntityType.SystemUser, Guid.Parse("ANOTHER_SYSTEMUSER_ID_TO_SEND_EMAIL"))
    .Cc(XrmEmail.ToEntityType.Queue, Guid.Parse("OPTIONAL_CC_QUEUE_ID"))
    .Subject("YOUR_EMAIL_SUBJECT")
    .Body("YOUR_EMAIL_BODY_CAN_BE_HTML")
    .Priority(PriorityCode.Normal);
    
    EmailHelper emailHelper = new EmailHelper(_organizationService);
    
    var emailId = emailHelper.Create(xrmEmail.ToEntity()); //YOU NEED TO CREATE EMAIL FIRST
    emailHelper.Send(emailId, "YOUR_EMAIL_SUBJECT");
  • Mohammed Fakhri Profile Picture
    Mohammed Fakhri 402 on at
    RE: I want to send email to the Business Unit (Email). I see that we are not able to set the partyid lookup to the Business Unit Entity. Is there any way to send email to the Business Unit entity, if i get the actual email id by querying upon the BU entity

    Hi Mahender,

    i understand that, but is there a way to send an email to just a plain email id through code ?

  • Suggested answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: I want to send email to the Business Unit (Email). I see that we are not able to set the partyid lookup to the Business Unit Entity. Is there any way to send email to the Business Unit entity, if i get the actual email id by querying upon the BU entity

    You can't send email to BU but you can get all the users/teams based on the BU and send email to them

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

Daivat Vartak – Community Spotlight

We are honored to recognize Daivat Vartak as our March 2025 Community…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Kudos to the February Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,409 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans