<p>I am using C# to process a message in my Outlook inbox that contains attachments.  One of the attachments is of type olEmbeddeditem.  I need to be able to process the contents of that attachment.  From what I can tell I need to save the attachment to disk and use CreateItemFromTemplate which would return an object.  </p>

<p>The issue I have is that an olEmbeddeditem can be any of the Outlook object types MailItem, ContactItem, MeetingItem, etc.  How do you know which object type a particular olEmbeddeditem attachment is going to be so that you know the object that will be returned by CreateItemFromTemplate?</p>

<p>Alternatively, if there is a better way to get olEmbeddeditem attachment contents into an object for processing I'd be open to that too.</p>

[{'answer_id': 96403, 'author': 'Community', 'author_id': -1, 'author_profile': 'https://Stackoverflow.com/users/-1', 'pm_score': 1, 'selected': False, 'text': '<p>I found the following code on Google Groups for determining the type of an Outlook object:</p>\n\n<pre><code>Type t = SomeOutlookObject.GetType();\nstring messageClass = t.InvokeMember("MessageClass",\n  BindingFlags.Public | \n  BindingFlags.GetField | \n  BindingFlags.GetProperty,\n  null,\n  SomeOutlookObject,\n  new object[]{}).ToString();\nConsole.WriteLine("\\tType: " + messageClass);\n</code></pre>\n\n<p>I don\'t know if that helps with an olEmbedded item, but it seems to identify regular messages, calendar items, etc.</p>\n'}, {'answer_id': 13089961, 'author': 'Duane Wright', 'author_id': 1759318, 'author_profile': 'https://Stackoverflow.com/users/1759318', 'pm_score': 0, 'selected': False, 'text': '<p>Working with email attachments that are also emails which in turn contains user defined properties that I want to access, then I perform the following steps:</p>\n\n<pre><code>Outlook.Application mailApplication = new Outlook.Application();\nOutlook.NameSpace mailNameSpace = mailApplication.GetNamespace(“mapi”);\n// make sure it is an embedded item\nIf(myAttachment.Type == Outlook.OlAttachmentType.olEmbeddeditem)\n{\n    myAttachment.Type.SaveAsFile(“temp.msg”);\n    Outlook.MailItem attachedEmail = (Outlook.MailItem)mailNameSpace.OpenSharedItem(“temp.msg”);\n    String customProperty = attachedEmail.PropertyAccessor.GetProperty(\n        “http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-c000-000000000046}/myProp\n}\n</code></pre>\n\n<p>If you open the MailItem using, then I will not have access to the properties as mentioned above:</p>\n\n<pre><code>Outlook.MailItem attachedEmail = (Outlook.MailItem)mailApplication.CreateFromTemplate(“temp.msg”);  \n</code></pre>\n'}]
['https://Stackoverflow.com/questions/82332', 'https://Stackoverflow.com', 'https://Stackoverflow.com/users/8391/']