B
Byron
I get an error, 0x80030002 "%1 could not be found.", when I try to
delete the second attachment from an rtf email message only in Outlook
2007. The first attachment gets processed with no problems. I've
tried getting a new Outlook::AttachmentsPtr and a new
Outlook::AttachmentPtr with no luck. The same code works for HTML and
Plain Text for Outlook 2007 as well as HTML, Plain Text, and RTF for
Outlook 2002 and 2003. Below is a snippet of code. Thanks.
pAttachment = pAttachments->Item(1);
m_csInputFile = m_csOutputPathFile = filepath;
originalFilename = (TCHAR*) pAttachment->GetFileName();
m_csInputFile += originalFilename;
m_csOutputPathFile += outfilename;
//Lets try and delete the files just in case the same filename exists
in the temp dir.
DeleteFile(m_csOutputPathFile);
DeleteFile(m_csInputFile);
BSTR bstr = m_csInputFile.AllocSysString();
if (FAILED(pAttachment->SaveAsFile(bstr)))
{
// If we can't save the attachment, we can't encrypt.
CString errMsg;
errMsg.Format(_T("An error was encountered when trying to encrypt
attachment %s.-*"), originalFilename);
AfxMessageBox(errMsg);
throw;
}
SysFreeString(bstr);
// It fails here on the second iteration.
if (FAILED(pAttachment->Delete()))
{
// If we can't remove the "clear text" attachment, we can't send.
CString errMsg;
errMsg.Format(_T("An error was encountered when trying to encrypt
attachment %s."), originalFilename);
AfxMessageBox(errMsg);
}
delete the second attachment from an rtf email message only in Outlook
2007. The first attachment gets processed with no problems. I've
tried getting a new Outlook::AttachmentsPtr and a new
Outlook::AttachmentPtr with no luck. The same code works for HTML and
Plain Text for Outlook 2007 as well as HTML, Plain Text, and RTF for
Outlook 2002 and 2003. Below is a snippet of code. Thanks.
pAttachment = pAttachments->Item(1);
m_csInputFile = m_csOutputPathFile = filepath;
originalFilename = (TCHAR*) pAttachment->GetFileName();
m_csInputFile += originalFilename;
m_csOutputPathFile += outfilename;
//Lets try and delete the files just in case the same filename exists
in the temp dir.
DeleteFile(m_csOutputPathFile);
DeleteFile(m_csInputFile);
BSTR bstr = m_csInputFile.AllocSysString();
if (FAILED(pAttachment->SaveAsFile(bstr)))
{
// If we can't save the attachment, we can't encrypt.
CString errMsg;
errMsg.Format(_T("An error was encountered when trying to encrypt
attachment %s.-*"), originalFilename);
AfxMessageBox(errMsg);
throw;
}
SysFreeString(bstr);
// It fails here on the second iteration.
if (FAILED(pAttachment->Delete()))
{
// If we can't remove the "clear text" attachment, we can't send.
CString errMsg;
errMsg.Format(_T("An error was encountered when trying to encrypt
attachment %s."), originalFilename);
AfxMessageBox(errMsg);
}