Pass custom Outlook properties on reply/reply all/forward

Add-in Express™ Support Service
That's what is more important than anything else

Pass custom Outlook properties on reply/reply all/forward
 
nwein




Posts: 510
Joined: 2011-03-28
Is it possible to include the original custom properties when forward/reply/reply all to an email with custom properties in it?
The ProcessReply event in the ADXOutlookItemEvents only has information regarding the newly created mail (the response object), not the original mail.
Thanks
Posted 23 Sep, 2014 15:28:45 Top
Andrei Smolin


Add-in Express team


Posts: 14115
Joined: 2006-05-11
Hello Nir,

You can read a UserProperty on the original email and use it's data to create a new UserProperty on the reply email. As to sending a UserProperty, please see http://support.microsoft.com/kb/907985/en-us and http://social.msdn.microsoft.com/Forums/vstudio/en-US/a5fa49d6-5f78-431e-9141-7eb572ec1500/how-to-prevent-userproperties-from-being-cleared-on-mailitemsend?forum=vsto.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 24 Sep, 2014 02:52:59 Top
nwein




Posts: 510
Joined: 2011-03-28
Thanks Andrei, though my question was more on how to associate one mail with another (i.e. the original mail and the one being replied - those are not the same mail item object, how can I tell which mail item it was originated from).
Posted 24 Sep, 2014 10:08:17 Top
Andrei Smolin


Add-in Express team


Posts: 14115
Joined: 2006-05-11
Nir,

You can only do this by intercepting the Reply, ReplyAll and Forward events of the original item and getting the response item in these events.

Regards from Belarus (GMT+3),

Andrei Smolin
Add-in Express Team Leader
Posted 24 Sep, 2014 10:16:47 Top
nwein




Posts: 510
Joined: 2011-03-28
Thanks again, I'll explore that option.
I do wonder however, how does Outlook "knows" when I reply to a message, and let's say it's not the latest one in a specific thread, that I'm not replying to the last message? (you know that message saying - "You are not responding to the latest message in this conversation, Click here to open it).
It seems like Outlook is aware of some sort of association between mails ,it also "knows" when I reply to an email by putting a message saying "You replied to this message on xxx".
Posted 24 Sep, 2014 10:25:07 Top
nwein




Posts: 510
Joined: 2011-03-28
I think I found the solution. This is the code I'm using to find a related message (I guess what I was trying to say in the above post was how to get related messages - similar to how Outlook works when clicking the Related button in the Editing group):
public MailItem FindParentMessage(MailItem mailItem)
{
	MAPIFolder folder = null;
	Items items = null;
	NameSpace ns = null;
	try
	{
		string strIndex = mailItem.ConversationIndex.Substring(0, mailItem.ConversationIndex.Length - 10);
		ns = OutlookApp.GetNamespace("MAPI");
		folder = ns.GetDefaultFolder(OlDefaultFolders.olFolderInbox);
		string strFind = "[ConversationTopic] = "" + mailItem.ConversationTopic + """;
		items = folder.Items.Restrict(strFind);
		if (items != null)
		{
			for (int i = 1; i <= items.Count; i++)
			{
				if (items[i] is MailItem)
				{
					var item = items[i] as MailItem;
					if (item.ConversationIndex == strIndex)
						return item;
					Marshal.ReleaseComObject(item);
				}
			}
		}
	}
	catch
	{
	  
	}
	finally
	{
		if (folder != null) Marshal.ReleaseComObject(folder);
		if (items != null) Marshal.ReleaseComObject(items);
		if (ns != null) Marshal.ReleaseComObject(ns);
	}
	return null;
}


The main thing to take from this is to search the folder (in this case - Inbox) for a conversation index truncated by 10 digits (5 bytes).

Also, it seems as if I didn't need to do anything special for forward - it automatically carried over the properties from the original mail, perhaps forward uses the same mail item? not sure, but it works :)
Posted 24 Sep, 2014 12:13:03 Top
Andrei Smolin


Add-in Express team


Posts: 14115
Joined: 2006-05-11
Posted 25 Sep, 2014 01:56:57 Top