Office外接Outlook API附加文档使用displayNewMessageForm方法问题 [英] Office Add-in Outlook API attach document using displayNewMessageForm method issue
问题描述
我正在使用Outlook的Office加载项.需要打开带有预定义附件的新邮件.
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
这是输出(我得到附件类型,id,大小等):
Here is an output (i get attachment type, id, size and so on):
然后我正尝试通过外接Outlook API将文件附加到Outlook中的新邮件中,这是
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.
推荐答案
根据 displayNewMessageForm
当前支持两种附件类型.要将文件附加到项目,附件对象应类似于...
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 ...
{
type: 'file',
name: 'image.png',
url: 'http://contoso.com/image.png',
isInline: true
}
要附加现有消息中的项目,对象应看起来...
To attach the item from existing message the object should looks ...
{
type: 'item',
name: 'image.png',
itemId: 'ews_item_id_goes_here'
}
这篇关于Office外接Outlook API附加文档使用displayNewMessageForm方法问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!