--

I need download to hard drive all documents and email attachments in
current folder.
Next code downloading only attachments. How can i access to documents?

void InsertMessages(IGWFolder* pIGWFolder,WCHAR* MyPath)
{
DIGWMessages* pDIGWMessages;
DIGWMessage* pDIGWMessage;
IGWMessages* pIGWMessages;
IGWMessage* pIGWMessage;
VARIANT vTmp;
long lCount;
int Count;
// Get messages object for folder
pIGWFolder->get_Messages(&pDIGWMessages);

// Get the interface for the messages object
if(!pDIGWMessages ||
FAILED(pDIGWMessages->QueryInterface(IID_IGWMessages,
(LPVOID*)&pIGWMessages))) {
cout<<"QueryInterface Failed on IID_IGWMessages"<<endl;
return;
}

pDIGWMessages->Release();

// How many messages are there?
pIGWMessages->get_Count(&lCount);

// Initialize variant
VariantInit(&vTmp);
V_VT(&vTmp) = VT_I2;


// Get lCount messages
Count = 0;
for(int i=1; i<lCount+1; i++)
{
V_I2(&vTmp) = i;

if(SUCCEEDED(pIGWMessages->Item(vTmp, &pDIGWMessage)))
{
if(!pDIGWMessage || FAILED(pDIGWMessage->QueryInterface(IID_IGWMessage,
(LPVOID*)&pIGWMessage))) {
cout<<"QueryInterface Failed on IID_IGWMessage"<<endl;
break;
}

pDIGWMessage->Release();
InsertAttachments(pIGWMessage,MyPath);

pIGWMessage->Release();

}
else
cout<<"pIGWMessages item failed"<<endl;
}
// Release message and folder objects
pIGWMessages->Release();

}


void InsertAttachments(IGWMessage* pIGWTmpMessage,WCHAR* MyPath)
{
BSTR NameMes,bStr;
IGWAttachments* pIGWAttachments;
IGWAttachment* pIGWAttachment;
DIGWAttachment* pDIGWAttachment;
DIGWAttachments* pDIGWAttachments;
pIGWTmpMessage->get_Attachments(&pDIGWAttachments);

// Get interface for attachments
if(pDIGWAttachments &&
SUCCEEDED(pDIGWAttachments->QueryInterface(IID_IGWAttachments,
(void**)&pIGWAttachments)))
{
pDIGWAttachments->Release();

long count;

pIGWAttachments->get_Count(&count);

if(count)
{
// declare local vars
VARIANT vIdx;
BSTR bstrName;
AttachmentTypeConstants attachType;
// Initialize variant and set type
VariantInit(&vIdx);
V_VT(&vIdx) = VT_I4;

for(int i=0; i<count; i++)
{
V_I4(&vIdx) = i + 1;
pIGWAttachments->Item(vIdx, &pDIGWAttachment);

if(pDIGWAttachment &&
SUCCEEDED(pDIGWAttachment->QueryInterface(IID_IGWAttachment,
(void**)&pIGWAttachment)))
{
pDIGWAttachment->Release();
pIGWAttachment->get_DisplayName(&bstrName);

// Get the attachment type
pIGWAttachment->get_ObjType(&attachType);

if(attachType != egwMessage)
{
wchar_t CurPath[1500];
wcscpy(CurPath,MyPath);
wcscat(CurPath,L"\\");
wcscat(CurPath,bstrName);
pIGWAttachment->Save(CurPath);
}
pIGWAttachment->Release();
}
}
}
}
pIGWAttachments->Release();
}