Update User mailAddress via Graph API

ram ra 20 Reputation points
2024-04-03T00:03:40.7633333+00:00

According to this document(Update user), it is included in the proxy address when updating the user.

What method should I use if I don't want to receive it with my past mail address?

User's image

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,021 questions
{count} votes

1 answer

Sort by: Most helpful
  1. Vasil Michev 105.8K Reputation points MVP
    2024-04-03T08:01:10.2633333+00:00

    Unfortunately, what you are asking for is not possible via the Graph API. Email addresses in general are managed by Exchange Online, and the Graph has almost no coverage of Exchange admin operations.

    To give you more context, the set of email addresses is stored within the proxyAddresses attribute. Said attribute is read-only to Graph however, and can only be set via Exchange tools, where it's also references as EmailAddresses. Here's an example of how to add or remove an address:

    Set-Mailbox A@domain.com -EmailAddresses @{add='B@domain.com'}
    Set-Mailbox A@domain.com -EmailAddresses @{remove='A@domain.com'}
    

    The mail property on the other hand is mapped to WindowsEmailAddress in Exchange. Updating said property is possible via Graph too, however the way it works is that it adds the value you specify as the primary SMTP address, while preserving any already existing addresses. You cannot use said property to replace or remove addresses. For such operations, you need to use Exchange Online PowerShell.

    You can find some additional details in the official documentation here: https://learn.microsoft.com/en-us/graph/api/resources/user?view=graph-rest-1.0#mail-and-proxyaddresses-properties

    0 comments No comments

Your answer

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