ews-javascript-api
ews-javascript-api copied to clipboard
Cannot get attachment of .EML type
Hello.
When reading emails with attachments in .EML format, we receive an error. Sorry in advance we can't use typescript. We use the version: 0.14.0 NodeJS version: v20.11.1
This comment does not work:
let items = await exch.FindItems(folderId, "isRead:false", view);
for (var item of items.Items) {
let res = await item.Load();
let attachs = [];
if (item.HasAttachments)
{
const exchangeAttachments = item.Attachments?.GetEnumerator() ?? [];
for await (const attachment of exchangeAttachments) {
const attachments = await exch.GetAttachments([attachment.Id], "HTML", []); //there's an error here
console.log('attachments', attachments);
const itemAttachment = attachments.Responses[0].Attachment;
await itemAttachment.Load();
console.log('attach', itemAttachment);
}
}
and getting error:
If we try to simply download the attachment:
let items = await exch.FindItems(folderId, "isRead:false", view);
for (const item of items.Items) {
let res = await item.Load();
if (item.HasAttachments)
{
for (const attach of item?.Attachments?.items) {
console.log('attach', attach);
let result = await attach.Load(); //there's an error here
}
}
}
and getting error:
Or other variant:
for (const attach of item?.Attachments?.items) {
console.log('attach', attach);
let result = await attach.Load([attach.id]); //there's an error here
// }
}
and getting error:
Maybe there is a solution to this problem? Thanks for the help.
Hi, I have a similar issue. I can get the ItemAttachment but its attribute "item" is empty, so I cannot retrieve anything of the eml attachment... but the name.
So no access to the body nor to the inner attachments. The method load on these attachments gives throw new ArgumentException_1.ArgumentException(ExtensionMethods_1.StringHelper.Format("The element at position {0} is invalid", count), paramName, e);
I am about to switch to python, a first prototype works...