email - Get specific Outlook attachment (OLE Automation C++) -


I can not find a specific Outlook (2013) email attachment. I am using C ++ about MS Office Automation I am working on a small project to learn and I am testing outlook automation. In the fraction, I want to download a specific email attachment, but I can not access that item. For example, if I have an email with 4 attachments in my inbox, then I should get another one. I tried with this code, but the value returned to HRESULT by the AutoWrap () method is not always valid:

  Diverse results; VariantInit (& amp; result); CComPtr & LT; IDispatch & gt; PAttachments; // Email attachment HRESULT hRes = Autodrop (DISPATCH_PROPERTYGET, and results, PofisITOM, L "attachment", 0); If returned (Result.pdispVal || FAILED (hRes)) EditorError; // EditorError An Enam Straps = Results pdispVal; VariantInit (& amp; result); HRS = Autodrop (DISPATCH_PROPERTYGET, and results, palettes, L "calculation", 0); If (FAILED (hRes)) EditorError; Int aNumber = result.iVal; // This works, if I have an email with 4 attachments, then a number is 4 if (aNumber> 0) {VARIANT attachmentIndex; AttachmentIndex.vt = VT_I4; AttachmentIndex.llVal = 0; // I want 1 attachment VariantInit (and the result); CComPtr & LT; IDispatch & gt; PAttachmentItem; HRS = Autodrop (DISPATCH_PROPERTYGET, and results, palettes, L "item", 1, attachment index); If (FAILED (hRes)) EditorError; // Enter this Return Editor here ...) Do something ...  

Where to interact with MS Application (), Autodewap () is the recommended method by MS.

Remarks:

The index property is valid only during the current session and the object Can be changed in the form and added to the collection In the first object in the collection, there is an index value of 1.


Comments