Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Get Attachment ContentID

I try to get the content ID's of the attachments of mails in outlook. I use Add-In Express for my Add-In, but it has no function to get it.

I know of the Redemption library, but it's not free and thus not an option for me.

In Outlook 2007+ there is the PropertyAccessor, which should me allow to do it, but I can't get it to work.

Here my code:

string uniqueId = "";
object props = a.GetType().InvokeMember("PropertyAccessor", BindingFlags.Public | BindingFlags.GetField | BindingFlags.GetProperty, null, a, null);
object[] args = new object[1];
args[0] = @"urn:schemas:mailheader:content-id";
object value = props.GetType().InvokeMember("GetProperty", BindingFlags.Public | BindingFlags.InvokeMethod, null, props, args);
if ((string)value != null) {
    uniqueId = (string)value;
}

"a" is an attachment gotten from an Add-In Express MailItem.

It just throws the following exception: "Exception has been thrown by the target of an invocation."

Can someone help me?

like image 342
Van Coding Avatar asked Mar 05 '26 06:03

Van Coding


1 Answers

I tried your URN as well and it did not work.

Using DASL, this works: http://schemas.microsoft.com/mapi/proptag/0x3712001F

Outlook Spy has a free trial period. I would download that in the meantime (which is where I found this value). And even when it expires, this valuable tool is less than Redemption itself.

like image 64
The Muffin Man Avatar answered Mar 07 '26 18:03

The Muffin Man



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!