4

I have a very special problem.

If we create a mail in Outlook, we add a UserProperty which contains a DataBase-ID of our System, so we can Link the mail to the representing DataBase-Item. On the service which reads the mails in each Mailbox and imports them automatically I can read this property by using ExtendedPropertyDefinitions. So far everything is fine...

If the User now forwards the message in Outlook, Olk copies the UserProperty to the new message. And now my problems beginn. Now my Service thinks the new message is also linked to our database and updates DB-Entry with the new Body and new Subject.

So does anyone now how to find out if a message is a forwarded one or how to tell Outlook not to copy the userproperty to the forwarded (new) message?

thx. Jay

What we thought about, but isnt working for our case
- a second userproperty containing a simple tag linke "fromSystem". Cause this would be copied too.
- a second userproperty containing a hashsum calculated from subject and Body. Cause both could be changed by the user. We just create the message, add all properties and Display it. from this Point on we no longer have control what is Happening to the mail until the Service handles it.

Jürgen Hoffmann
  • 947
  • 4
  • 15
  • How are you creating the **Database-ID** `UserProperty` in Outlook? – SliverNinja - MSFT Nov 30 '12 at 16:19
  • @SilverNinja, here's a sample-vb code that does the same as the real code. Dim m As MailItem Dim p As UserProperty Set m = Application.CreateItem(olMailItem) m.Recipients.Add "test@test.de" m.Subject = "Testemail" m.Body = "Testmail - Body" Set p = m.UserProperties.Add("KonLfdNr", olText) p.Value = "123456789" m.Display – Jürgen Hoffmann Dec 02 '12 at 14:02

1 Answers1

7

Your service consuming EWS should check the ConversationIndex and only update the database if it's 22 bytes long (original source message). Forward emails and reply emails keep appending 5 bytes (10 chars) to the ConversationIndex extending it beyond 22 bytes.

Sample ConversationIndexes

Original: 01CDD15D80E51C1D4522172840ACA96287DA28A15D97
Reply:    01CDD15D80E51C1D4522172840ACA96287DA28A15D970000018630
Forward:  01CDD15D80E51C1D4522172840ACA96287DA28A15D970000018630000000FC30

ConversationIndex represents the sequential ordering of the ConversationTopic (essentially GUID + timestamp). See Working with Conversations on MSDN. ConversationIndex is explicitly defined on MSDN here.

 if (message.ConversationIndex.Length == 22)
 {
   // update DB body, subject, etc.
 }

Also make sure you load the EmailMessageSchema.ConversationIndex before trying to access its value.

Community
  • 1
  • 1
SliverNinja - MSFT
  • 31,051
  • 11
  • 110
  • 173