ews-javascript-api
ews-javascript-api copied to clipboard
"Preflight response is not successful" error, using ews-js-api-browser in Outlook add ins on Mac OS
var exch = new EwsJS.ExchangeService(EwsJS.ExchangeVersion.Exchange2019);
exch.Credentials = new EwsJS.WebCredentials("user","password"); // any fake stuff needed, it is not used properly
exch.Url = new EwsJS.Uri("https://outlook.office365.com/Ews/Exchange.asmx"); // anything valid url
var view = new EwsJS.ItemView(1);
exch.FindItems(EwsJS.WellKnownFolderName.Inbox, "hasattachment:true", view)
.then((response) => {
EwsJS.EwsLogging.Log(response.Items[0].Id, true, true);
EwsJS.EwsLogging.Log(response.TotalCount, true, true);
let email = response.Items[0];
console.log(email);
email.Load(new EwsJS.PropertySet(EwsJS.BasePropertySet.IdOnly, [EwsJS.ItemSchema.Attachments,EwsJS.ItemSchema.HasAttachments, EwsJS.ItemSchema.MimeContent])).then(() => {
console.log(email.HasAttachments);
let file = email.Attachments.Items[0];
file.Load().then(() => {
console.log(file.Base64Content);
console.log(Buffer(file.Base64Content,"base64").toString());
}, (error) => {
if (error) {
console.log(error)
}
});
}, (error) => {
if (error) {
console.log(error)
}
});
}, (error) => {
if (error) {
console.log(error)
}
});
Hi Gautam, Can you please tell me what could be wrong here?
We may have to discuss possible option for cors issue if you are working in corp environment.
I can provide consulting for same.
Yes, this is corporate mail. In Safari, I turned on "Disable cross-origin restriction." but that didn't help.
connect with me on linkedin (link on profiel page)