Share via

Microsoft Graph API - Is it possible to send an email with a "plus identifier"?

Maxime Duchêne-Savard 0 Reputation points
2023-06-16T03:01:36.7733333+00:00

Hi,

I'm trying to send an email from another account using an app.

If the email is sent from the account with the original name, it works fine, however, adding a "plus identifier" causes à 'SendAsDeniedError'.

Works: ******@my.host.com
Does not work: ******@my.host.com

Is there a workaround for this?

Java sample code:

    Message someMessage = new Message();
    someMessage.from = new Recipient();
    someMessage.from.emailAddress = new EmailAddress();
    someMessage.from.emailAddress.address = "******@my.host.com"; // Email sent successfully
    someMessage.from.emailAddress.address = "******@my.host.com"; // Causes 'ErrorSendAsDenied'

    someMessage.toRecipients =
        List.of("******@my.host.com").stream()
            .map(
                ea -> {
                  Recipient recipient = new Recipient();
                  recipient.emailAddress = new EmailAddress();
                  recipient.emailAddress.address = ea;
                  return recipient;
                })
            .toList();

    someMessage.body = new ItemBody();
    someMessage.body.content = "Some content";
    graphClient
        .users("******@my.host.com")
        .sendMail(UserSendMailParameterSet.newBuilder().withMessage(someMessage).build())
        .buildRequest()
        .post();
Microsoft Security | Microsoft Graph
0 comments No comments

1 answer

Sort by: Most helpful
  1. Md Asif Muztaba 340 Reputation points Microsoft External Staff
    2023-12-29T04:58:46.65+00:00

    The ‘SendAsDeniedError’ typically occurs when you’re trying to send an email with a sender different from your login address. In your case, you’re trying to send an email from “******@my.host.com” which might not have the necessary permissions.

    Here are a few potential workarounds:

    1. Check Permissions: Ensure that the account “******@my.host.com” has the necessary ‘Send-As’ permissions.
    2. Use a Shared Mailbox: If you’re using Microsoft Power Automate, you could try using the “Send an email from a shared mailbox (Preview)” step instead of the “Send Email (v2)” step.
    3. Remove the Plus Identifier: If possible, try sending the email without the plus identifier (i.e., use “@my.host.com” instead of “@my.host.com”).

    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".

    Was this answer helpful?

    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.