A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Add-ins for Outlook
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Error deleting second attach from RTF Msg w/ Outlook 2007



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old September 6th 07, 07:06 PM posted to microsoft.public.outlook.program_addins
Byron
external usenet poster
 
Posts: 9
Default Error deleting second attach from RTF Msg w/ Outlook 2007

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);
}

  #2  
Old September 7th 07, 08:14 PM posted to microsoft.public.outlook.program_addins
Byron
external usenet poster
 
Posts: 9
Default Error deleting second attach from RTF Msg w/ Outlook 2007

Could someone w/ a known good add-in test this out? I've stripped out
all the code in the Send event except for what's neccessary for
deleting attachments and it still fails with 0x80030002 "%1 could not
be found.". Here is what I have in the send event.

case 0xf005: // Send
try
{
Outlook::_MailItemPtr mailPtr = NULL;
mailPtr = m_pItem-GetMailItem();
int attCount = mailPtr-GetAttachments()-GetCount();
for (int i = attCount; i 0 ; i--)
{
mailPtr-GetAttachments()-Item(i)-Delete();
}
}
catch(...)
{
CString errMsg;
errMsg.Format(_T("An error was encountered when trying to --Delete--
attachment"));
AfxMessageBox(errMsg);
}


On Sep 6, 2:06 pm, Byron wrote:
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);



}- Hide quoted text -

- Show quoted text -



  #3  
Old September 12th 07, 01:41 PM posted to microsoft.public.outlook.program_addins
Byron
external usenet poster
 
Posts: 9
Default Error deleting second attach from RTF Msg w/ Outlook 2007

Finally found a solution to the problem. Simple call Save on the
MailItem before trying to process the next attachment.

case 0xf005: // Send
try
{
Outlook::_MailItemPtr mailPtr = NULL;
mailPtr = m_pItem-GetMailItem();
int attCount = mailPtr-GetAttachments()-GetCount();
for (int i = attCount; i 0 ; i--)
{
mailPtr-GetAttachments()-Item(i)-Delete();
mailPtr-Save();
}
}

catch(...)
{
CString errMsg;
errMsg.Format(_T("An error was encountered when trying to --
Delete--
attachment"));
AfxMessageBox(errMsg);

}


On Sep 7, 3:14 pm, Byron wrote:
Could someone w/ a known good add-in test this out? I've stripped out
all the code in the Send event except for what's neccessary for
deleting attachments and it still fails with 0x80030002 "%1 could not
be found.". Here is what I have in the send event.

case 0xf005: // Send
try
{
Outlook::_MailItemPtr mailPtr = NULL;
mailPtr = m_pItem-GetMailItem();
int attCount = mailPtr-GetAttachments()-GetCount();
for (int i = attCount; i 0 ; i--)
{
mailPtr-GetAttachments()-Item(i)-Delete();
}}

catch(...)
{
CString errMsg;
errMsg.Format(_T("An error was encountered when trying to --Delete--
attachment"));
AfxMessageBox(errMsg);

}

On Sep 6, 2:06 pm, Byron wrote:



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);


}- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -



  #4  
Old September 13th 07, 07:36 PM posted to microsoft.public.outlook.program_addins
Byron
external usenet poster
 
Posts: 9
Default Error deleting second attach from RTF Msg w/ Outlook 2007

And of course 2 days later I run across the online documentation,
should have looked there instead of using VBAOL10.CHM.

http://msdn2.microsoft.com/en-us/lib...ffice.10).aspx

(Last Line on page)
"To ensure consistent results, always save an item before adding or
removing objects in the Attachments collection of the item."


On Sep 12, 8:41 am, Byron wrote:
Finally found a solution to the problem. Simple call Save on the
MailItem before trying to process the next attachment.

case 0xf005: // Send
try
{
Outlook::_MailItemPtr mailPtr = NULL;
mailPtr = m_pItem-GetMailItem();
int attCount = mailPtr-GetAttachments()-GetCount();
for (int i = attCount; i 0 ; i--)
{
mailPtr-GetAttachments()-Item(i)-Delete();
mailPtr-Save();
}

}

catch(...)
{
CString errMsg;
errMsg.Format(_T("An error was encountered when trying to --
Delete--
attachment"));
AfxMessageBox(errMsg);

}

On Sep 7, 3:14 pm, Byron wrote:



Could someone w/ a known good add-in test this out? I've stripped out
all the code in the Send event except for what's neccessary for
deleting attachments and it still fails with 0x80030002 "%1 could not
be found.". Here is what I have in the send event.


case 0xf005: // Send
try
{
Outlook::_MailItemPtr mailPtr = NULL;
mailPtr = m_pItem-GetMailItem();
int attCount = mailPtr-GetAttachments()-GetCount();
for (int i = attCount; i 0 ; i--)
{
mailPtr-GetAttachments()-Item(i)-Delete();
}}


catch(...)
{
CString errMsg;
errMsg.Format(_T("An error was encountered when trying to --Delete--
attachment"));
AfxMessageBox(errMsg);


}


On Sep 6, 2:06 pm, Byron wrote:


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);


}- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -- Hide quoted text -


- Show quoted text -



 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Microsoft Outlook 2007 - deleting messages after reading Frustrated with upgrading Outlook - Installation 3 August 13th 07 08:09 AM
Outlook 2007 Task Form Insert Ribbon (Attach Group) [email protected] Outlook - General Queries 9 April 26th 07 07:38 PM
Outlook 2007 Calender Appointment Not Deleting Ray May Outlook - Calandaring 0 April 9th 07 07:52 PM
Cannot Attach File with Outlook 2007 Rob Schneider Outlook - General Queries 1 April 7th 07 02:14 PM
Error deleting contacts Mervin Williams Outlook - Using Contacts 3 April 12th 06 10:24 AM


All times are GMT +1. The time now is 11:38 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.