我怎么知道来自两个不同邮箱的两封电子邮件是相同的?

How can I know that two emails are the same from two different mailboxes?

如果我将同一封电子邮件发送到两个不同的邮箱,我希望能够判断这些是否是同一封电子邮件。

问题是两封电子邮件的 itemId 不同。而且我想不出从两封相同的电子邮件中获得唯一标识符的方法。

从 JS 中的 Office 对象,我只能通过以下方式获得 itemId (有所不同): Office.context.mailbox.item.itemId : Documentation

所以我一直在尝试通过以下方式从 EWS Managed API 中找到其他内容:

EmailMessage.Bind(service, mail.ItemId, new PropertySet(ItemSchema.Id));

但我无法从 ItemSchema 中找到任何有用的 属性。 (ItemSchema documentation)

当两封邮件在两个不同的邮箱时,我怎么知道它们是相同的?

有没有办法比较两个 ID?

没有 100% 的答案。它们实际上是两个独立的副本,因此它们之间没有实际的 link。您也许能够检索 RFC 822 消息 ID(尝试 InternetMessageHeaders 属性)并进行比较,但您会假设在检索之前没有任何内容修改该值。

我想在@JasonJohnston 的回答中添加一些代码。

C#

[HttpPost]
public List<InternetMessageHeader> GetMailHeader(MailRequest request) {
    ExchangeService service = new ExchangeService();
    service.Credentials = new OAuthCredentials(request.AuthenticationToken);
    service.Url = new Uri(request.EwsUrl);

    ItemId id = new ItemId(request.ItemId);
    EmailMessage email = EmailMessage.Bind(service, id, new PropertySet(ItemSchema.InternetMessageHeaders));

    if (email.InternetMessageHeaders == null)
        return null;

    return email.InternetMessageHeaders.ToList();
}

JS(这里用的是AngularJS,你懂的)

// Request headers from server
getMailHeader()
  .then(function(response) {
    var headers = response.data;
    var messageId = findHeader("Message-ID"); // Here you get the Message-ID

    function findHeader(name) {
      for (var i in headers) {
        if (name == headers[i].Name) {
          return headers[i].Value;
        }
      }
      return null;
    }
  }, function(reason) {
    console.log(reason);
  });

function getMailHeader() {
  var promise = $q(function(resolve, reject) {
    // Office.context.mailbox.getCallbackTokenAsync(callback);
    outlookService.getCallbackTokenAsync(function(asyncResult, userContext) {
      if (asyncResult.status == "succeeded") {
        $http({
          method: "POST",
          url: serverUrl + "/api/exchange/getMailHeader",
          data: JSON.stringify({
            authenticationToken: asyncResult.value,
            ewsUrl: outlookService.ewsUrl, // Office.context.mailbox.ewsUrl
            itemId: outlookService.itemId // Office.context.mailbox.item.itemId
          })
        }).then(resolve, reject);
      } else {
        reject("ERROR");
      }
    });
  });
  return promise;
}