如何通过会话将单个电子邮件分组,以便我确定(100%)一封电子邮件与另一封电子邮件在同一会话中? [英] How can I group individual emails by conversation, so that I know for sure (100%) that one email is in the same conversation as the other?

查看:95
本文介绍了如何通过会话将单个电子邮件分组,以便我确定(100%)一封电子邮件与另一封电子邮件在同一会话中?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题

使用Exchange WebServices API时,如何通过会话将单个电子邮件分组,以便我确定(100%)一封电子邮件与另一封电子邮件在同一会话中?

How can I group individual emails by conversation when using the Exchange WebServices API so that I know for sure (100%) that one email is in the same conversation as the other?

我个人的意思是:我应该一次可以下载1封电子邮件,因为发送了较晚的回复(例如,回复上个月的电子邮件),我不想批量下载整个对话,但是只有一封电子邮件能够将其存储在我自己的数据库中.

By individual I mean: I should be able to download 1 email at a time, since when a late response is sent (let's say as a reply to an email from last month), I don't want to bulk-download the whole conversation again, but just that one email to be able to store it in my own database.

上下文

我正在一个项目中,我需要将所有新电子邮件都放入MySQL数据库中,以便我们可以从CRM应用程序中添加额外的元数据.现在,我正在使用基于XML的Exchange WebServices API进行原型设计,以便我知道可用的数据以及数据的外观.我正在用PHP(也是内置CRM的语言)进行此操作.

I am working on a project where I need to put all fresh emails in a MySQL database so that we can add extra meta data from out of our CRM application. Right now I am doing some prototyping with the Exchange WebServices API over XML so that I know what data is available and what it looks like. I am doing this in PHP (also the language our CRM is built in).

问题

当运行一个简单的XML请求(见下文)时,我从收件箱/句子文件夹中收到了一些电子邮件.因为我知道我与一位同事进行了一次对话以测试ConversationIndex,所以我发现ConversationIndex似乎并没有像我期望的那样是一个索引.我希望所有电子邮件都一样,这样我就可以轻松地将一个对话分组在一起.

When running a simple XML request (see below) I receive some emails from my inbox/sentitems folder. Since I know I had a conversation with a colleague to test the ConversationIndex I found out that the ConversationIndex doesn't seem to be an index as I expected it to be. I expected it to be equal on all emails so that I could easily group one conversation together.

但是,事实并非如此.因为当我将一个收件箱的收件箱和snetitems的ConversationIndexes并排放置时,会得到以下结果:(--> sentitem, <-- inbox)

But that doesn't appear to be true. Because when I lay the ConversationIndexes of my inbox and snetitems (of one conversation) next to each other I get the following result: (--> sentitem, <-- inbox)

  1. -> Ac9IKUBx8yX3vSXYQSWcb8ggCfC7FQ==(第一个项目)
  2. <-Ac9IKUBx8yX3vSXYQSWcb8ggCfC7FQAAAT1A(回复1)
  3. -> Ac9IKUBx8yX3vSXYQSWcb8ggCfC7FQAAAT1AAAAHYQA=(回复2)
  4. <-Ac9IKUBx8yX3vSXYQSWcb8ggCfC7FQAAAT1AAAAHYQAAAAScMA==(回复3)
  5. -> Ac9IKUBx8yX3vSXYQSWcb8ggCfC7FQAAAT1AAAAHYQAAAAScMAAACBsQ(回复4)
  6. <-Ac9IKUBx8yX3vSXYQSWcb8ggCfC7FQAAAT1AAAAHYQAAADX4EA==(回复5)
  7. <-Ac9IKUBx8yX3vSXYQSWcb8ggCfC7FQAAP7ZQ(回复1)
  1. --> Ac9IKUBx8yX3vSXYQSWcb8ggCfC7FQ== (first sentitem)
  2. <-- Ac9IKUBx8yX3vSXYQSWcb8ggCfC7FQAAAT1A (reply to 1)
  3. --> Ac9IKUBx8yX3vSXYQSWcb8ggCfC7FQAAAT1AAAAHYQA= (reply to 2)
  4. <-- Ac9IKUBx8yX3vSXYQSWcb8ggCfC7FQAAAT1AAAAHYQAAAAScMA== (reply to 3)
  5. --> Ac9IKUBx8yX3vSXYQSWcb8ggCfC7FQAAAT1AAAAHYQAAAAScMAAACBsQ (reply to 4)
  6. <-- Ac9IKUBx8yX3vSXYQSWcb8ggCfC7FQAAAT1AAAAHYQAAADX4EA== (reply to 5)
  7. <-- Ac9IKUBx8yX3vSXYQSWcb8ggCfC7FQAAP7ZQ (reply to 1)

其他会话示例会话索引:Ac9IB53hRlE85QAKR9qCJ8pbv8gikwAAtByQ

您可以看到,除前30个字符外,每封电子邮件的ConversationIndex都会发生变化.通过参考此问题的答案发现的另一件事是,我应该使用BitConverter并修改ConverationIndex,但这是对于C#.我也找不到为此的PHP解决方案.

As you can see the ConversationIndex changes for every email except for the first 30 characters. Another thing I found out by consulting the answer on this question is that I should use a BitConverter and modify the ConverationIndex but that is for C#. I couldn't find a PHP solution for this neither.

此外,我在EWS文档中找不到与此主题有关的任何信息(例如:

Also, I can't find any information on this subject in the EWS docs (for example: http://msdn.microsoft.com/en-us/library/ms528174(v=exchg.10).aspx).

可能的选择

我在来自Exchange服务器的XML响应中看到一个References键,但是使用这些InternetMessageId来确定电子邮件所处的会话将变成一个真正的地狱.

I saw a References key in the XML response from the Exchange server, but using those InternetMessageId's to determine what conversation an email is in would become a true hell.

我注意到的另一件事是ConversationId(

Another thing I noticed was the ConversationId (http://msdn.microsoft.com/en-us/library/ff387041%28v=office.12%29.aspx) but that doesn't seem to be what I'm look for neither.

XML请求,仅供参考

<?xml version="1.0" encoding="utf-8"?>
<soap:Envelope xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/"
               xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types">
    <soap:Body>
        <FindItem xmlns="http://schemas.microsoft.com/exchange/services/2006/messages"
                  xmlns:t="http://schemas.microsoft.com/exchange/services/2006/types"
                  Traversal="Shallow">
            <ItemShape>
                <t:BaseShape>AllProperties</t:BaseShape>
            </ItemShape>
            <IndexedPageItemView MaxEntriesReturned="5" Offset="0" BasePoint="Beginning" />
            <ParentFolderIds>
                <t:DistinguishedFolderId Id="inbox OR sentitems"/>
            </ParentFolderIds>
        </FindItem>
    </soap:Body>
</soap:Envelope>

更新1

似乎我必须使用ConversationId而不是索引.尽管目前我正在开发Exchange 2007,但我们很快将升级到2013.有人可以验证我确实必须使用ConversationId吗?

It looks like I have to use the ConversationId instead of the index. Although I am working on Exchange 2007 at the moment we are upgrading to 2013 very soon. Can somebody verify that I have to use the ConversationId indeed?

推荐答案

Jelmer-

我最近写了如何:通过在MSDN上使用Exchange中的EWS 进行对话. GetConversationItems EWS操作Exchange 2013中引入的功能是您要用来检索特定对话中的所有内容的功能. GetConversationItems使用 ConversationId 元素,不在Exchange 2007中. ConversationTopic ConversationIndex 出现在Exchange 2007中-我假设您可以使用另一种操作来查找具有特定ConversationTopic的所有项目,但我不必这样做.如果您需要这种方法的帮助,请告诉我.

I recently wrote the How to: Work with conversations by using EWS in Exchange article on MSDN. The GetConversationItems EWS operation, which was introduced in Exchange 2013, is what you want to use to retrieve everything in a specific conversation. GetConversationItems uses the ConversationId element, which wasn't around in Exchange 2007. ConversationTopic and ConversationIndex were around in Exchange 2007 - and I would assume you could use another operation to find all items with a specific ConversationTopic, but I haven't had to do that. If you want help with that approach, let me know.

ConversationThread是您在上面的第一条消息上标识的值(Ac9IKUBx8yX3vSXYQSWcb8ggCfC7FQ),然后,每次响应,转发等项目时,ConversationIndex都会递增.

The ConversationThread is the value you identified above (Ac9IKUBx8yX3vSXYQSWcb8ggCfC7FQ), on the first message, then the ConversationIndex is incremented every time the item is responded to, forwarded, etc.

来自文章:"Exchange将相同的ConversationTopic值应用于第一条消息的答复,然后更新ConversationIndex值以表示该消息相对于原始消息的位置.如果电子邮件线程的主题发生变化,则Exchange将应用新的ConversationTopic值和新的ConversationIndex新对话的价值."

From the article: "Exchange applies the same ConversationTopic value to replies to the first message and then updates the ConversationIndex value to represent the message’s position relative to the original message. If the subject of the email thread changes, Exchange applies a new ConversationTopic value and new ConversationIndex values to the new conversation."

我注意到您在帖子中称为EWS文档的实际上是CDO文档. Exchange 2013的EWS参考内容位于: http ://msdn.microsoft.com/zh-CN/library/bb204119(v = exchg.150).aspx . Exchange 2007的EWS参考内容(如果您想进行比较)位于:

I noticed that what you referred to in your post as the EWS docs is actually the CDO docs. The EWS reference content for Exchange 2013 is located here: http://msdn.microsoft.com/en-us/library/bb204119(v=exchg.150).aspx. And the EWS reference content for Exchange 2007 (if you want to compare), is here: http://msdn.microsoft.com/en-us/library/bb204119(v=exchg.80).aspx.

希望这会有所帮助,如果我确实回答了您的问题,请将该帖子标记为已回答.

Hope this helps and please mark the post as answered if I did indeed answer your question.

谢谢, 咪咪

于3/27更新,以回答有关ConversationId的其他问题:

Updated on 3/27 to respond to additional questions about ConversationId:

我只是想办法解决这个问题,如果更改主题,ConversationId确实会更改,但是只要消息被转发并回复,它就保持不变.我原来的ConversationId是:

I just played around with this to be sure and the ConversationId does change if the subject is changed, but it stays the same so long as the message is just forwarded and replied to. My original ConversationId was:

<ConversationId Id="AAQkADI2MDY4MjQzLWQ1YzQtNGZkNi1iZmE4LTRjZmZmNGEyZjQ0YwAQAJJCqNI7ZfhJmIh7j2kgJvk=" />
<ConversationTopic>Original</ConversationTopic>

但是两次更改主题后,它看起来像这样:

but after changing the subject twice it looked like this:

<ConversationId Id="AAQkADI2MDY4MjQzLWQ1YzQtNGZkNi1iZmE4LTRjZmZmNGEyZjQ0YwAQAEjf5yU/W9VMo6HxuanvhYE=" />
<ConversationTopic>2nd subject</ConversationTopic>

所以前X个字符是相同的,但是有区别.

So the first X characters are the same, but then there's divergence.

这篇关于如何通过会话将单个电子邮件分组,以便我确定(100%)一封电子邮件与另一封电子邮件在同一会话中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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