如何在outlook插件中获取附件? [英] How get attachments in outlook plugin?

查看:60
本文介绍了如何在outlook插件中获取附件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我如何获取附件并将​​其发送到我的 Java 服务器?
在文档中说:

Hi how can i get attachments and send it to my java server?
in docs its say:

var item = Office.context.mailbox.item;
var options = {asyncContext: {currentItem: item}};
item.getAttachmentsAsync(options, callback);

function callback(result) {
  if (result.value.length > 0) {
    for (i = 0 ; i < result.value.length ; i++) {
      result.asyncContext.currentItem.getAttachmentContentAsync(result.value[i].id, handleAttachmentsCallback);
    }
  }
}

function handleAttachmentsCallback(result) {
  // Parse string to be a url, an .eml file, a base64-encoded string, or an .icalendar file.
  switch (result.value.format) {
    case Office.MailboxEnums.AttachmentContentFormat.Base64:
      // Handle file attachment.
      break;
    case Office.MailboxEnums.AttachmentContentFormat.Eml:
      // Handle email item attachment.
      break;
    case Office.MailboxEnums.AttachmentContentFormat.ICalendar:
      // Handle .icalender attachment.
      break;
    case Office.MailboxEnums.AttachmentContentFormat.Url:
      // Handle cloud attachment.
      break;
    default:
      // Handle attachment formats that are not supported.
  }
}

但是我在这个例子中有几个错误.首先是 item.getAttachmentsAsync 不是函数
然后我尝试使用
result.asyncContext.currentItem.getAttachmentContentAsync(item.attachments[2].id, handleAttachmentsCallback);
但它从未被称为回调

But i have several errors witch this example. first is item.getAttachmentsAsync is not a function
then im tried to use
result.asyncContext.currentItem.getAttachmentContentAsync(item.attachments[2].id, handleAttachmentsCallback);
but its never called calback

如何获取附件并通过 XMLHttpRequest 将它们发送到我的服务器?

How can i get attachments and send them by XMLHttpRequest to my server?

推荐答案

阅读模式:https://docs.microsoft.com/en-us/office/dev/add-ins/outlook/get-attachments-of-an-outlook-item?view=outlook-js-preview

撰写模式:https://docs.microsoft.com/en-us/office/dev/add-ins/outlook/add-and-remove-attachments-to-an-item-in-a-compose-form?view=outlook-js-preview

但是,正如 Jadams 的回答中提到的,读取模式支持 getAttachmentContentAsync,您可以将其获取到附件的 Base64 编码.(第一个链接将很快更新以反映这一点)

However, as mentioned in Jadams answer, getAttachmentContentAsync IS supported in Read Mode, and you can get that to the the Base64 encoding of attachments. (the first link will be updated soon to reflect this)

这篇关于如何在outlook插件中获取附件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆