我正在使用Outlook的办公室加载项。需要使用预定义的附件打开新邮件。
尝试从当前项目(消息)获取附件,如下所示:
Office.context.mailbox.item.attachments
这是一个输出(我得到附件类型,id,大小等):
然后我尝试通过外接程序Outlook API将此文件附加到Outlook中的新邮件,这是Office Developer中的一个示例,我用它来附加我从其他电子邮件中获取的文件(喜欢'前进'功能):
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
}
]
});
这是一个问题:我得到一个例外'价值不在预期范围内'。参数名称:附件。
非常感谢帮助。
答案 0 :(得分:1)
根据displayNewMessageForm
上的文档,目前支持两种附件类型。要将文件附加到项目,附件对象应该看起来像......
{
type: 'file',
name: 'image.png',
url: 'http://contoso.com/image.png',
isInline: true
}
要附加现有消息中的项目,对象应该看起来......
{
type: 'item',
name: 'image.png',
itemId: 'ews_item_id_goes_here'
}