Share via

Create Email Distribution list baaded on Email Domain

Shrikant Bhagwat 146 Reputation points
2026-03-14T01:12:41.89+00:00

I want to create 2 different distribution list based on user's Email Domain,

I have two domain

abc.com

xyz.com

I want to create Distribution Lists

abc-dl.abc.com with users ******@abc.com, ******@abc.com, etc

xyz-dl.zyz.com with users ******@zyz.com, ******@xyz.com, etc.

2026-03-13_20-51-50

Let us know. Is Custom Attribute Entra based or Exchange Based.

Let me know

Shrikant

Exchange Online
Exchange Online

A cloud-based service included in Microsoft 365, delivering scalable messaging and collaboration features with simplified management and automatic updates.


2 answers

Sort by: Most helpful
  1. Vasil Michev 126K Reputation points MVP Volunteer Moderator
    2026-03-14T07:36:44.8866667+00:00

    Unfortunately, Microsoft updated the way Dynamic distribution group filters work a while back, so you cannot directly create a rule based on the "email domain" anymore (see https://practical365.com/dynamic-distribution-group-wildcard/ if you want additional details).

    Instead, you can use other attributes, where applicable, or leverage the set of customAttributeXX, like on your screenshot above. You will have to manually populate those values, either in your on-premises AD (if you are syncing objects) or in Exchange Online (for cloud-created objects). PowerShell can of course help with that, here's an example:

    Get-Mailbox -Filter {UserPrincipalName -like "*@domainA.com"} | Set-Mailbox -CustomAttribute1 blabla
    

    Note that I am using the UserPrincipalName value here, as we cannot leverage the same operators with PrimarySmtpAddress (see the link above). In most cases, the UPN value should match the primary alias, so you should be fine. If you must use the PrimarySmtpAddress value instead, you can only do so via client-side filtering:

    Get-Mailbox -ResultSize Unlimited | ? {$_.PrimarySmtpAddress -like "*@domainA.com"} | Set-Mailbox -CustomAttribute1 blabla
    

    Once you've done with setting the attribute values, you can use the UI to create the DDG, or do it via PowerShell:

    New-DynamicDistributionGroup -Name blabla -RecipientFilter {CustomAttribute1 -eq "blabla"}
    
    0 comments No comments

  2. Q&A Assist
    2026-03-14T01:12:56.5266667+00:00
    AI generated content. This question contains an answer created with AI from Q&A Assist. Learn more

    Custom attributes used for dynamic or filtered distribution groups are Exchange recipient properties.

    To build the two lists by email domain in Exchange Online, use dynamic distribution groups and filter on a property that distinguishes the domains (for example, a custom attribute populated differently for abc.com and xyz.com users):

    1. Populate a custom attribute on the mailboxes:
      • For abc.com users, set CustomAttribute1 = "ABC".
      • For xyz.com users, set CustomAttribute1 = "XYZ".
    2. Create dynamic distribution groups in Exchange Online PowerShell using those attributes, for example:
    New-DynamicDistributionGroup \
      -Name "abc-dl" \
      -RecipientFilter "(RecipientTypeDetails -eq 'UserMailbox') -and (CustomAttribute1 -eq 'ABC')"
    
    New-DynamicDistributionGroup \
      -Name "xyz-dl" \
      -RecipientFilter "(RecipientTypeDetails -eq 'UserMailbox') -and (CustomAttribute1 -eq 'XYZ')"
    

    These groups will automatically include all user mailboxes whose CustomAttribute1 matches the specified value. The custom attributes themselves are stored and evaluated in Exchange (they are part of the mailbox/recipient object) and are then visible in Entra ID via directory synchronization, but their use for dynamic distribution group membership is an Exchange feature.


    References:

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.