ฉันจะรู้ได้อย่างไรว่าอีเมลสองฉบับจากกล่องจดหมายสองกล่องเหมือนกัน

ถ้าฉันส่งอีเมลเดียวกันไปยังกล่องจดหมายสองกล่อง ฉันต้องการทราบว่าอีเมลเหล่านี้เป็นอีเมลเดียวกันหรือไม่

ปัญหาคือ itemId แตกต่างกันสำหรับอีเมลทั้งสองฉบับ และฉันไม่สามารถหาวิธีที่จะมีตัวระบุที่ไม่ซ้ำจากอีเมลสองฉบับที่เหมือนกันได้

จากวัตถุ Office ใน JS ฉันจะได้รับเฉพาะ itemId (ที่แตกต่างกันไป) ผ่าน : Office.context.mailbox.item.itemId : เอกสาร

ดังนั้นฉันจึงพยายามค้นหาสิ่งอื่นจาก EWS Managed API ผ่าน:

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

แต่ฉันไม่พบคุณสมบัติที่มีประโยชน์จาก ItemSchema (เอกสารประกอบ ItemSchema< /ก>)

ฉันจะรู้ได้อย่างไรว่าอีเมลสองฉบับเหมือนกันเมื่ออยู่ในกล่องจดหมายสองกล่อง

มีวิธีเปรียบเทียบสอง id หรือไม่?


comment
@MrPiao หากคุณอ่านรหัสที่ฉันให้มา ฉันกำลังใช้วัตถุ Office ที่มาจากบริบทของ office365-apps   -  person Elfayer    schedule 14.02.2016
comment
คุณพูดถูก ความผิดของฉัน   -  person MrPiao    schedule 18.02.2016


คำตอบ (2)


ไม่มีคำตอบ 100% สำหรับเรื่องนี้ จริงๆ แล้วมันเป็นสำเนาสองชุดแยกกัน ดังนั้นจึงไม่มีความเชื่อมโยงระหว่างกันจริงๆ คุณอาจดึง ID ข้อความ RFC 822 ได้ (ลองใช้คุณสมบัติ InternetMessageHeaders) และเปรียบเทียบสิ่งนั้น แต่คุณจะถือว่าไม่มีสิ่งใดแก้ไขค่านั้นก่อนที่คุณจะดึงมัน

person Jason Johnston    schedule 08.02.2016
comment
สิ่งที่สามารถเปลี่ยนแปลง Message-ID ? - person Elfayer; 08.02.2016
comment
ตัวแทนการขนส่ง เซิร์ฟเวอร์ใดๆ ก็ตามในห่วงโซ่การจัดส่ง (แม้ว่าอาจจะไม่ควรก็ตาม) แอปอื่นๆ ที่เข้าถึงข้อความ ฯลฯ - person Jason Johnston; 08.02.2016

ฉันต้องการเพิ่มรหัสในคำตอบของ @JasonJohnston

ซี#

[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;
}
person Elfayer    schedule 09.02.2016