简体   繁体   English

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

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

If I send the same email to two different mailboxes, I'd like to be able to tell if these are the same email. 如果我将相同的电子邮件发送到两个不同的邮箱,则希望能够确定它们是否是相同的电子邮件。

The problem is that the itemId is different for the two emails. 问题是这两封电子邮件的itemId不同。 And I can't figure a way to have a unique identifier from two identical emails. 而且我找不到从两个相同的电子邮件中获得唯一标识符的方法。

From Office object in JS, I only get the itemId (that vary) via : Office.context.mailbox.item.itemId : Documentation 从JS中的Office对象,我只能通过以下方式获取itemId (不同): Office.context.mailbox.item.itemId文档

So I've been trying to find something else from EWS Managed API via: 因此,我一直在尝试通过以下方法从EWS托管API中找到其他内容:

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

But I can't find any useful property from ItemSchema . 但是我无法从ItemSchema找到任何有用的属性。 ( ItemSchema documentation ) ItemSchema文档

How can I know that two emails are the same when they are in two different mailboxes ? 我如何知道两个不同的邮箱中的两个电子邮件相同?

Is there a way to compare two ids ? 有没有办法比较两个ID?

There is no 100% answer for this. 没有100%的答案。 They are actually two separate copies, so there is no actual link between them. 它们实际上是两个单独的副本,因此它们之间没有实际的链接。 You might be able to retrieve the RFC 822 message ID (try the InternetMessageHeaders property) and compare that, but you'd be assuming that nothing modified that value before you retrieved it. 您也许能够检索RFC 822消息ID(尝试使用InternetMessageHeaders属性)并进行比较,但是您将假定在检索该值之前没有任何修改。

I wanted to add some code to @JasonJohnston answer. 我想在@JasonJohnston答案中添加一些代码。

C# 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 (using AngularJS here, but you get the idea) 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;
}

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从两个不同的子文件夹将两个版本的相同程序集加载到两个不同的域中? - How can I load two versions of same assemblies into two different domains from two different subfolders? Microsoft DI:如果两个不同的类在其构造函数参数中采用相同的类型,我如何从配置中为它们注入不同的值? - Microsoft DI: If two different classes take the same type in their constructor params, how can I inject different values for them from configuration? 如何在一个代码中从两个不同的表中进行选择? - How can i Select from two different tables in one code? 如何在不同的表中映射两个具有相同主键的不同外键? - How can I map two different foreign key with same primary key in different table? 如何知道两个单词是否具有相同的基数? - How to know if two words have the same base? 如何在wpf上的两个不同窗口中绑定两个控件? - How can I bind two controls in two different windows on wpf? 我怎样才能匹配两个不同的列表? - How can i match two different List? 我可以使用具有两个不同母版页的相同内容页面吗? - Can I use the same content page with two different master pages? 我可以在两个不同的表的两个不同关系中使用同一个实体吗? - Can I use the same entity in two different relationship with two different tables? 如何使两个不同的线程在同一时间写入变量? C# - How can I make two different threads write to a variable at the exact same time? C#
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM