gautamsi / ews-javascript-api

EWS API for TypeScript/JavaScript - ported from OfficeDev/ews-managed-api - node, cordova, meteor, Ionic, Electron, Outlook Add-Ins
MIT License
282 stars 73 forks source link

Problem with EmailMessage.Update #447

Open JuanMurciaN opened 1 month ago

JuanMurciaN commented 1 month ago

Library is not able to update an EmailMessage Body

The following code will work on C# to change the body of an email

ExchangeService ewsClient; // A properly authenticated EWS service object tied to a mailbox
string emailID; // A valid email ID for that mailbox

var message = EmailMessage.Bind(ewsClient, new ItemId(emailID));
message.Body = new MessageBody(0, "<p>This is the replaced body</p>");

message.Update(ConflictResolutionMode.AlwaysOverwrite);

In the other hand, it's equivalent on javascrypt throws Exception: The request failed schema validation.

const ewsClient: ExchangeService; // A properly authenticated EWS service object tied to a mailbox
const emailID: string; // A valid email ID for that mailbox

const message = await EmailMessage.Bind(ewsClient, new ItemId(emailID));
message.Body = new MessageBody(0,'<p>This is the replaced body</p>');

await message.Update(ConflictResolutionMode.AlwaysOverwrite);
gautamsi commented 1 month ago

what happens when you use BodyType.HTML instead of 0

JuanMurciaN commented 1 month ago

Making sure the correct type is being used, the Update call is successful, but email is left with no body at all