[英]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.