G
Guest
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
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