0
votes

I need to send via email a pin from an android app to a mail group using Outlook Mail REST API. How can I achieve this? I can't find anything about groups on the documentation.

I want to avoid to store the admin users in a static config file and POST a request to "https://outlook.office.com/api/v2.0/me/sendmail" with a JSON content like:

{
  "Message": {
    "Subject": "ADMIN PIN FOR ANDROID APP",
    "Body": {
      "ContentType": "Text",
      "Content": "The secret pin is: 12345"
    },
    "ToRecipients": [ // ( list generated from config file )
      {
        "EmailAddress": {
          "Address": "[email protected]"
        }
      },
      {
        "EmailAddress": {
          "Address": "[email protected]"
        }
      }
    ],
    "Attachments": [
      {
        "@odata.type": "#Microsoft.OutlookServices.FileAttachment",
        "Name": "menu.txt",
        "ContentBytes": "bWFjIGFuZCBjaGVlc2UgdG9kYXk="
      }
    ]
  },
  "SaveToSentItems": "false"
}

Thanks

1
what do you mean by contacts group, is it meaning mail group?Jeffrey Chen
@JeffreyChen-MSFT yes thanksGabe

1 Answers

1
votes

When you create an email group , you will have a email address target to this group(you could find the address in the property of the group) . With the address, you could call Outlook Mail REST API to send your message : Create and send messages via Outlook Mail REST API

In addition, the group only accepts messages from people in its organization or on its allowed senders list. If you cannot send the email , you could ask the owner of the group to grant you permission to send to it, and then try again .