Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Any user can send email in D365 setting 'From' to a shared mailbox

(0) ShareShare
ReportReport
Posted on by 29

Users send emails from D365 both from themselves and from a shared mailbox by updating the 'From'
This shared mailbox is setup as a queue which has now been set to Private and specific members added.

The mailbox has been Approved, Tested and enabled

The problem though is that any user can change the 'From' in this shared mailbox and then send a mail
We want to be able to restrict who can do this.

*This post is locked for comments

  • Suggested answer
    Kokulan Profile Picture
    18,054 on at
    RE: Any user can send email in D365 setting 'From' to a shared mailbox

    Hi

    Suggested JavaScript approach is one way to go about it.

    If you wanted to make sure the system does not send the email at all if the from should not be changed to particular user or queue, you can create a real-time workflow that triggers on (before) status change of the email record. Check the from field and the modified by user and if you think the email should not be sent with that from, you can use Stop Workflow step with an error message so that system will display an error message to the user saying you cant send this email.

    Let me know if you need any screenshots or examples for this.

  • cloflyMao Profile Picture
    25,208 on at
    RE: Any user can send email in D365 setting 'From' to a shared mailbox

    Hi Marc,

    For first question:

    Yes, it'll only block From field when current user is not administrator or any specific user, but you could integrate this part of script with your own business logic.

    For second question:

    If you want to restrict user to select specific mailbox, you could execute script below when form onLoad.

    I've added comments for how it works.

    // execute this function when form onLoad
    function FromFieldRestriction() {
        // register onChange event to From field
        Xrm.Page.getAttribute("from").addOnChange(checkUser);
    }

    function checkUser() {
        // execute checking function when there is a selected value/mailbox in From field
        if (typeof Xrm.Page.getAttribute("from").getValue()[0] !== 'undefined') {
            var user = Xrm.Page.context.getUserName();
            // get selected mailbox name
            var mailbox = Xrm.Page.getAttribute("from").getValue()[0].name;
            // check whether current user is allowed to change mailbox
            isRestrictedMailbox(user, mailbox);
        }
    }

    function isRestrictedMailbox(user, mailbox) {
        if (user == 'userA') {
            // restricted mailbox array
            var restrictedMailboxes = ['mailboxA'];
            // check whether the selected mailbox is existed in restricted mailbox array
            var flag = restrictedMailboxes.indexOf(mailbox);
            if (flag != -1) {
                var alertStrings = { text: "You're not allowed to select this mailbox, please select aother." };
                var alertOptions = { height: 120, width: 260 };
                // open a CRM alert dialog and set From field to null
                Xrm.Navigation.openAlertDialog(alertStrings, alertOptions).then(function () { });
                Xrm.Page.getAttribute("from").setValue(null);
            }
        }
    }

    Regards,

    Clofly

  • MarcJ Profile Picture
    29 on at
    RE: Any user can send email in D365 setting 'From' to a shared mailbox

    Thank you... so this will not prevent a user being able to send an email from their own id's, it will just stop them changing the From to another id ?

    Is it possible to also check what they are changing it to ie. I do not want userA changing From to mailboxA but they can change it to mailboxB ?

  • cloflyMao Profile Picture
    25,208 on at
    RE: Any user can send email in D365 setting 'From' to a shared mailbox

    Hi Partner,

    You could insert following script with getControl().setDisabled(true) function into your Email form to lock From field,

    just with your own business logic.

    function checkUser() {
      var user = Xrm.Page.context.getUserName();
      if (user != "MOD Administrator") {
        Xrm.Page.getControl("from").setDisabled(true);
      }
    }

    xxz.png

    Regards,

    Clofly

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

🌸 Community Spring Festival 2025 Challenge Winners! 🌸

Congratulations to all our community participants!

Adis Hodzic – Community Spotlight

We are honored to recognize Adis Hodzic as our May 2025 Community…

Kudos to the April Top 10 Community Stars!

Thanks for all your good work in the Community!

Leaderboard > Microsoft Dynamics CRM (Archived)

#1
Mohamed Amine Mahmoudi Profile Picture

Mohamed Amine Mahmoudi 83 Super User 2025 Season 1

#2
Community Member Profile Picture

Community Member 52

#3
dkrishna Profile Picture

dkrishna 6

Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans