Issue:
When attempt to use Microsoft Graph API to Forward an email O365 doesn't deliver it with error:
Remote Server returned '550 5.7.708 Service unavailable. Access denied, traffic not accepted from this IP. For more information please go to http://go.microsoft.com/fwlink/?LinkId=526653 AS(7171) [DM6PR09MB5976.namprd09.prod.outlook.com]'
Attached is JS code:
<script type="text/javascript">
function getItemRestId() {
if (Office.context.mailbox.diagnostics.hostName === 'OutlookIOS') {
// itemId is already REST-formatted.
return Office.context.mailbox.item.itemId;
} else {
// Convert to an item ID for API v2.0.
return Office.context.mailbox.convertToRestId(
Office.context.mailbox.item.itemId,
Office.MailboxEnums.RestVersion.v2_0
);
}
}
const clientId = "CLIENTID"; // Client Id of the registered application
const callback = (errorDesc, token, error, tokenType) => {};
const graphScopes = ["user.read", "mail.send", "Mail.ReadWrite"]; // An array of graph scopes
const authConfig = {
auth: {
clientId: "APPID",
// OLD CONFIG authority: "https://login.microsoftonline.com/APPID"
authority: "https://login.microsoftonline.com/APPID/"
}
}
const msalOptions = new MicrosoftGraph.MSALAuthenticationProviderOptions(graphScopes);
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#initialization-of-msal
const userAgentApplication = new Msal.UserAgentApplication(authConfig);
const authProvider = new MicrosoftGraph.ImplicitMSALAuthenticationProvider(userAgentApplication, msalOptions, graphScopes);
const options = {
authProvider,
redirectUri:"https://app1.azurewebsites.net/MessageRead.html"
};
const client = MicrosoftGraph.Client.initWithMiddleware(options);
const forward = {
comment: "This is the comment field",
toRecipients: [
{
emailAddress: {
name: "John Doe",
address: "ORGANIZATION EMAIL (INTERNAL)"
}
}
]
// saveToSentItems: "false"
};
async function forwardPhising(){
let id = getItemRestId();
let forwd = await client.api('/me/messages/' + id + '/forward')
.post(forward);
return forwd;
}
</script>
No clue why O365 is blocking its own IP addresses.
Article:
https://docs.microsoft.com/en-us/graph/api/message-forward?view=graph-rest-1.0&tabs=javascript
I am getting the same issue and error. Using Graph to forward an email. It worked ok on 29 Dec 2019 and now not working today.
Murray curious what your Javascript looks like to do your forward because it's never worked for me. I'd be happy to share with you what my Javascript looks like to compare.
Get Outlook for iOShttps://aka.ms/o0ukef
From: Murray Sinclair notifications@github.com
Sent: Wednesday, January 1, 2020 8:17:07 PM
To: microsoftgraph/microsoft-graph-docs microsoft-graph-docs@noreply.github.com
Cc: Mike Altamore Michael.Altamore@microsoft.com; Author author@noreply.github.com
Subject: Re: [microsoftgraph/microsoft-graph-docs] Forward Mail Not working on O365 Organizational Internal or External Email. (#6690)
I am getting the same issue and error. Using Graph to forward an email. It worked ok on 29 Dec 2019 and now not working today.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoftgraph%2Fmicrosoft-graph-docs%2Fissues%2F6690%3Femail_source%3Dnotifications%26email_token%3DANDTOM2I2XTPP2UIX3P6GBTQ3U6BHA5CNFSM4KAHSW52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEH5QOZA%23issuecomment-570099556&data=02%7C01%7CMichael.Altamore%40microsoft.com%7Cb3bb34c3d6884dc5850808d78f217c2e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637135246294614588&sdata=Ws19vErdbr7uTzEFBLXHIgcZRBISLCYl7b7n8Jx2mc0%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FANDTOM6Z5Z7OPEVY36NW2W3Q3U6BHANCNFSM4KAHSW5Q&data=02%7C01%7CMichael.Altamore%40microsoft.com%7Cb3bb34c3d6884dc5850808d78f217c2e%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637135246294624578&sdata=am3gDyUJe3pWrEuLyWakv69Kg%2FMZTslyjkQQYd0sGmo%3D&reserved=0.
Hi,
I'm using Java (Spring Boot). I can still send you the code but may not be useful if you are not a Java developer.
Not a Java developer persay but i can read the code well enough. I'll send you my Javascript incase you were interested in that method.
Get Outlook for iOShttps://aka.ms/o0ukef
From: Murray Sinclair notifications@github.com
Sent: Wednesday, January 1, 2020 8:25:05 PM
To: microsoftgraph/microsoft-graph-docs microsoft-graph-docs@noreply.github.com
Cc: Mike Altamore Michael.Altamore@microsoft.com; Author author@noreply.github.com
Subject: Re: [microsoftgraph/microsoft-graph-docs] Forward Mail Not working on O365 Organizational Internal or External Email. (#6690)
Hi,
I'm using Java (Spring Boot). I can still send you the code but may not be useful if you are not a Java developer.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoftgraph%2Fmicrosoft-graph-docs%2Fissues%2F6690%3Femail_source%3Dnotifications%26email_token%3DANDTOM2DAWMUNHSV7D4V36DQ3U67DA5CNFSM4KAHSW52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEH5QTEQ%23issuecomment-570100114&data=02%7C01%7CMichael.Altamore%40microsoft.com%7C7d54f36f17294726a7cc08d78f22995c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637135251077477219&sdata=t3ttZJ6yEq4mr6qvzxjn%2FhU1f8fw%2FXnvhqaGTIpWOH4%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FANDTOM43HD6TFI3F7ZAOMULQ3U67DANCNFSM4KAHSW5Q&data=02%7C01%7CMichael.Altamore%40microsoft.com%7C7d54f36f17294726a7cc08d78f22995c%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637135251077477219&sdata=aR7lWaZNcfDzXZR%2FS%2BkI9y4HlXzRXPtHNn3iHA7OmN8%3D&reserved=0.
Here you go (for some reason the first part of the code is showing as a comment and the second part is showing as code):
String urlString = baseUrl + "messages/" + movedMessage.getId() + "/forward";
URL url = new URL(urlString);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
try {
connection.setRequestMethod("POST");
connection.setRequestProperty("Authorization", "Bearer " + accessToken);
connection.setRequestProperty("Accept", "application/json");
connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
connection.setRequestProperty("Prefer", "IdType=\"ImmutableId\"");
connection.setDoOutput(true);
StringBuilder payload = new StringBuilder("{");
payload.append("\"toRecipients\": [");
payload.append("{");
payload.append("\"emailAddress\": {");
payload.append("\"name\": \"Processor\",");
payload.append("\"address\": \"").append(configService.getConfiguration().getEmailAddress()).append("\"");
payload.append("}");
payload.append("}");
payload.append("]");
payload.append("}");
try (OutputStream os = connection.getOutputStream()) {
byte[] input = payload.toString().getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
StringBuilder response = new StringBuilder();
String responseLine;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
}
} catch (IOException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
Murray,
Here is mine used for some testing:
<script type="text/javascript">
function getItemRestId() {
if (Office.context.mailbox.diagnostics.hostName === 'OutlookIOS') {
// itemId is already REST-formatted.
return Office.context.mailbox.item.itemId;
} else {
// Convert to an item ID for API v2.0.
return Office.context.mailbox.convertToRestId(
Office.context.mailbox.item.itemId,
Office.MailboxEnums.RestVersion.v2_0
);
}
}
const clientId = "{GUID_ID}"; // Client Id of the registered application
const callback = (errorDesc, token, error, tokenType) => {};
const graphScopes = ["user.read", "mail.send", "Mail.ReadWrite"]; // An array of graph scopes
const authConfig = {
auth: {
clientId: "{GUID_ID}",
authority: "https://login.microsoftonline.com/{GUID}"
//OLD authority: "https://login.microsoftonline.com/{GUID}oauth2/token"
}
}
//NEW STUFF BELOW
var graphConfig = {
};
//NEW STUFF END
const msalOptions = new MicrosoftGraph.MSALAuthenticationProviderOptions(graphScopes);
// Initialize the MSAL @see https://github.com/AzureAD/microsoft-authentication-library-for-js/wiki/MSAL-basics#initialization-of-msal
//NEW STUFF BEGIN
function acquireTokenPopupAndCallMSGraph() {
//Always start with acquireTokenSilent to obtain a token in the signed in user from cache
myMSALObj.acquireTokenSilent(requestObj).then(function (tokenResponse) {
callMSGraph(graphConfig.graphMeEndpoint, tokenResponse.accessToken, graphAPICallback);
}).catch(function (error) {
console.log(error);
// Upon acquireTokenSilent failure (due to consent or interaction or login required ONLY)
// Call acquireTokenPopup(popup window)
if (requiresInteraction(error.errorCode)) {
myMSALObj.acquireTokenPopup(requestObj).then(function (tokenResponse) {
callMSGraph(graphConfig.graphMeEndpoint, tokenResponse.accessToken, graphAPICallback);
}).catch(function (error) {
console.log(error);
});
}
});
}
//NEW STUFF END
const userAgentApplication = new Msal.UserAgentApplication(authConfig);
const authProvider = new MicrosoftGraph.ImplicitMSALAuthenticationProvider(userAgentApplication, msalOptions, graphScopes);
const options = {
authProvider,
redirectUri:"Message.html"
};
const client = MicrosoftGraph.Client.initWithMiddleware(options);
const forward = {
message: {
toRecipients: [
{
emailAddress: {
name: "John Doe",
address: "[email protected]"
}
}
]
},
comment: "This email was forwarded using graph API"
};
async function forwardPhising(){
let id = getItemRestId();
let forwd = await client.api('/me/messages/{id}/forward')
.post(forward);
console.log(forwd);
let delm = await client.api('/me/messages/' + id)
.delete()
return forwd;
return delm;
}
From: Murray Sinclair notifications@github.com
Sent: Wednesday, January 1, 2020 8:38 PM
To: microsoftgraph/microsoft-graph-docs microsoft-graph-docs@noreply.github.com
Cc: Mike Altamore Michael.Altamore@microsoft.com; Author author@noreply.github.com
Subject: Re: [microsoftgraph/microsoft-graph-docs] Forward Mail Not working on O365 Organizational Internal or External Email. (#6690)
Here you go:
String urlString = baseUrl + "messages/" + movedMessage.getId() + "/forward";
URL url = new URL(urlString);
HttpURLConnection connection = (HttpURLConnection) url.openConnection();
try {
connection.setRequestMethod("POST");
connection.setRequestProperty("Authorization", "Bearer " + accessToken);
connection.setRequestProperty("Accept", "application/json");
connection.setRequestProperty("Content-Type", "application/json; charset=UTF-8");
connection.setRequestProperty("Prefer", "IdType="ImmutableId"");
connection.setDoOutput(true);
StringBuilder payload = new StringBuilder("{");
payload.append("\"toRecipients\": [");
payload.append("{");
payload.append("\"emailAddress\": {");
payload.append("\"name\": \"Processor\",");
payload.append("\"address\": \"").append(configService.getConfiguration().getEmailAddress()).append("\"");
payload.append("}");
payload.append("}");
payload.append("]");
payload.append("}");
try (OutputStream os = connection.getOutputStream()) {
byte[] input = payload.toString().getBytes(StandardCharsets.UTF_8);
os.write(input, 0, input.length);
}
try (BufferedReader br = new BufferedReader(new InputStreamReader(connection.getInputStream(), StandardCharsets.UTF_8))) {
StringBuilder response = new StringBuilder();
String responseLine;
while ((responseLine = br.readLine()) != null) {
response.append(responseLine.trim());
}
}
} catch (IOException e) {
e.printStackTrace();
}
} catch (IOException e) {
e.printStackTrace();
}
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHubhttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fmicrosoftgraph%2Fmicrosoft-graph-docs%2Fissues%2F6690%3Femail_source%3Dnotifications%26email_token%3DANDTOM76TTNIY2QNYFBD3GLQ3VAOPA5CNFSM4KAHSW52YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEH5Q2FY%23issuecomment-570101015&data=02%7C01%7CMichael.Altamore%40microsoft.com%7C0265ada27de54439386808d78f245cf6%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637135258656026539&sdata=hTdh3Rk6yyrW8%2FOgCh%2BL%2FXtO25i5LJrUBjqGztMd%2BfQ%3D&reserved=0, or unsubscribehttps://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FANDTOM7IEBBZDU42JQPDO3LQ3VAOPANCNFSM4KAHSW5Q&data=02%7C01%7CMichael.Altamore%40microsoft.com%7C0265ada27de54439386808d78f245cf6%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C637135258656026539&sdata=I2getNfKMzFhtNfcC4xUbcIX%2BaO4fwzgUqk8YxIVEXQ%3D&reserved=0.
We are experiencing the same issue in one of the E5 Dev Tenants. Emails are no longer delivered when sending via MS Graph since December 13th, 2019. We are trying to get help from Microsoft support to see if there is anything that can be done. Will add some news here if I have any.

Interesting fact: emails arrive just fine if we send them via Outlook. But there is something wrong when using graph.
@Zerg00s Any update from your case on this?
@mialtamo, we've created a ticket via the Office 365 website. Spent some time confirming that Exchange Online works perfectly well: emails are sent and received just fine when using Outlook. However, when Graph sends emails, these emails are bouncing back since December 13th.
Yesterday we were forced to close the first ticket and open a new one via the Azure portal. I've been waiting for a call from support, but nothing yet.
@Zerg00s its recommendeby going though skepital ATM, to remove the IP address being blocked by going to https://sender.office.com. I have done this and am waiting on results they recommended a 24hr wait time. Will update if results prove worthy.
@Zerg00s its recommendeby going though skepital ATM, to remove the IP address being blocked by going to https://sender.office.com. I have done this and am waiting on results they recommended a 24hr wait time. Will update if results prove worthy.
Dont think this is viable all my rejections are from different addresses and I dont plan on going through probably hundres if not thousands of IP addreses to delist.
This issue will be closed because we do not support feedback captured directly from github new issue page. Also, this issue list is not intended for service issues, questions or service feedback.
To provide feedback on content on Microsoft Graph documentation, please scroll to the bottom of the content page to the Feedback section on docs.microsoft.com. You can create new feedback there. This gives the team the complete context of what content feedback you have.
If you have service issues and want to raise a support request. Please either:
If you would like to ask a question about Microsoft Graph, please visit Stack Overflow and ask your questions there using [microsoft-graph] tag.
If you have suggestions or feedback on Microsoft Graph, please submit this at Microsoft Graph Uservoice.
Hi, anyone got this issue resolved? or any update on the ticket?