I need to get messages that have a specific address in the CC field. I've tried to get messages this way:
Outlook.Folder folder = (Outlook.Folder) this.Application.Session.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox);
string cc = "[email protected]";
string filter = @"@SQL=(""urn:schemas:httpmail:cc"" LIKE '%" + cc + @"')";
Outlook.Items restrictedItems = folder.Items.Restrict(filter);
In this way all messages with addresses that are displayed in Outlook itself in the "CC" field as addresses are found. But the problem is that this way does not find messages whose addresses are not directly displayed (as on the screenshot):
I also tried to compose a query with "urn:schemas:httpmail:displaycc", but no luck either. Is there any way to write a filter so that I can only get messages that have a specific address in the "CC" field?
For example, I had a similar problem when filtering messages by sender. This article http://philliphoff.github.io/finding-dasl-property-names/# helped me. Thanks to it, I added "http://schemas.microsoft.com/mapi/proptag/0x0065001f" and "http://schemas.microsoft.com/mapi/proptag/0x0042001f" to my query and everything worked fine
The real CC address (same for the recipient) was only obtained here:
You can scroll through the list of messages and look for the presence of the desired address in them. I don't think this is the most optimal method, but I managed to solve the problem this way. I have not found any other solution