ews-javascript-api icon indicating copy to clipboard operation
ews-javascript-api copied to clipboard

Problem with EmailMessage.Update

Open JuanMurciaN opened this issue 1 year ago • 2 comments
trafficstars

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);

JuanMurciaN avatar Oct 11 '24 22:10 JuanMurciaN

what happens when you use BodyType.HTML instead of 0

gautamsi avatar Oct 12 '24 04:10 gautamsi

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

JuanMurciaN avatar Oct 15 '24 15:10 JuanMurciaN