N
nikolayds via OfficeKB.com
Hi all,
I am new in outlook addin programming, so naturally I am getting a setback
right away .
Problem: need to get the attachaments of email
Code:
(Version one - no Redemption)
This one is getting the first attachment but blows on subsequent with read
violation error.
Using redemption
Any ideas what I am doing wrong?
I am new in outlook addin programming, so naturally I am getting a setback
right away .
Problem: need to get the attachaments of email
Code:
(Version one - no Redemption)
Code:
Outlook::Attachments* na = pMailItem->Attachments;
int count = na->Count;
Outlook::Attachment* att;
_variant_t inx =0;
for(int t=1;t<=count; t++)
{
inx = t;
att = na->Item(inx);
int type = att->Type;
CString filename = (BSTR) att->FileName;
}
violation error.
Using redemption
Code:
IAttachmentsPtr spAttachments = spSafeMailItem->Attachments;
for(int j=1; j<=spAttachments->Count; j++)
{
HRESULT _thr;
_variant_t inx = j;
IAttachmentPtr pAttachment;
_thr = spAttachments->raw_Item(inx, &pAttachment);//->get__Item(inx,
&pAttachment);
// getting E_UNEXPECTED
if(_thr!=S_OK)
{
continue;
}
long size = pAttachment->FileSize;
CString fname = (BSTR) pAttachment->FileName;
if(pAttachment->Type == 1) //ByValue
{
CString path = "C:\\";
path.Append(fname);
_thr = pAttachment->SaveAsFile(path.AllocSysString());
if(_thr==S_OK)
{
int a = 0;
}
}
}
Any ideas what I am doing wrong?