I'm working on office Add-in for Outlook. Need to open a new message with a pre-defined attachment.
Trying to get an attachment from the current item (message) as below:
Office.context.mailbox.item.attachments
Here is an output (i get attachment type, id, size and so on):
Then I'm trying to attach this file to a new message in Outlook via add-in outlook API, here is an example from Office Developer that I use to attach the file I just get from the other email (like 'forward' functionality):
Office.context.mailbox.displayNewMessageForm(
{
toRecipients: Office.context.mailbox.item.to, // Copy the To line from current item
ccRecipients: ['sam@contoso.com'],
subject: 'Outlook add-ins are cool!',
htmlBody: 'Hello <b>World</b>!<br/><img src="cid:image.png"></i>',
attachments: [
{
type: 'file',
name: 'image.png',
url: 'http://contoso.com/image.png',
isInline: true
}
]
});
Here is an issue: I'm getting an exception 'Value doesn't fall within the expected range'. Parameter name: Attachments.
Help is really appreciated.
According to documentation on
displayNewMessageForm
there are currently two attachment types are supported. To attach file to the item the attachment object should looks like ...To attach the item from existing message the object should looks ...