Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Outlook / Programming Add-Ins / August 2005

Tip: Looking for answers? Try searching our database.

Get binaries of attachments

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Sektor - 25 Aug 2005 16:15 GMT
Hi all,
How can I get attachment binary data without saving it on a file?
I try with the following code but HrGetOneProp give me E_OUTOFMEMORY if the
attachment is 670 KB.

HRESULT GetAttachmentBinaryProp(Outlook::Attachment *atch, std::vector<byte>
&binProp)
{
   if (!atch)
       return E_FAIL;
   HRESULT hr;
   CComQIPtr<Outlook::Attachment> attachment(atch);
   CComPtr<IUnknown> mapiObj;
   hr = attachment->get_MAPIOBJECT(&mapiObj);
   if (FAILED(hr))
       return hr;
   LPSPropValue lpProps = NULL;
   hr = HrGetOneProp((LPMAPIPROP)(IUnknown*)mapiObj, PR_ATTACH_DATA_BIN,
&lpProps);
   if( lpProps && lpProps->ulPropTag==ulPropTag && lpProps->Value.bin.cb )
   {
       memcpy(&binProp[0], lpProps->Value.bin.lpb, binProp.size());
       return S_OK;
   } else
   {
       return E_FAIL;
   }
}

Everything works well if the attachment is little (e.g. 4 KB).
Could anyone help me?
Thanks
Sektor
Dmitry Streblechenko - 25 Aug 2005 18:07 GMT
All (potentially) large string or binary propeties (such for PR_BODY and
PR_RTF_COMPRESSED for the messages or PR_ATTACH_DATA_BIN for attachments)
must be opened as an IStream (mapiObj->OpenProperty(PR_ATTACH_DATA_BIN,
&IID_IStream, ...)).

Dmitry Streblechenko (MVP)
http://www.dimastr.com/
OutlookSpy  - Outlook, CDO
and MAPI Developer Tool

> Hi all,
> How can I get attachment binary data without saving it on a file?
[quoted text clipped - 29 lines]
> Thanks
> Sektor
Sektor - 25 Aug 2005 22:30 GMT
Thanks.
Sektor.

> All (potentially) large string or binary propeties (such for PR_BODY and
> PR_RTF_COMPRESSED for the messages or PR_ATTACH_DATA_BIN for attachments)
[quoted text clipped - 40 lines]
>> Thanks
>> Sektor
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.