Microsoft KB Archive/919454

= The message body still shows a message attachments that you deleted by using the Outlook Object Model in Outlook 2002 and in Office Outlook 2003 =

Article ID: 919454

Article Last Modified on 1/12/2007

-

APPLIES TO


 * Microsoft Outlook 2002 Standard Edition
 * Microsoft Office Outlook 2003

-





SYMPTOMS
Consider the following scenario. You create an e-mail message in Microsoft Outlook 2002 or in Microsoft Office Outlook 2003. You add an attachment to the e-mail message. All the following conditions are true:
 * You are using Outlook to connect to a Microsoft Exchange mailbox that has exceeded its storage limit.
 * You are running Outlook in online mode.
 * You are using Microsoft Office Word as the e-mail message editor.
 * You are composing messages in Rich Text Format (RTF).

In this scenario, when you delete the attachment from the e-mail message in the Item_Write event of the Outlook Object Model, the message body still shows the attachment.

Additionally, if you try to send or to save the e-mail message the first time, the Mailbox Cleanup dialog box appears as expected. However, if you try to send or to save the e-mail message again, you receive the following error message:

The operation failed.



STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed in the &quot;Applies to&quot; section.



Steps to reproduce the problem
 Set up an Exchange mailbox that exceeds its storage limit. Start Outlook, and then connect to the Exchange mailbox.  On the Tools menu, point to Macro, and then click Visual Basic Editor. Paste the following Visual Basic for Applications (VBA) code example into the code window.

Note This VBA code example deletes all the attachments for a message by using the Outlook Object Model. Dim WithEvents olInsp As Outlook.Inspectors Dim WithEvents myItem As Outlook.MailItem Dim WithEvents myInsp As Outlook.Inspector Private Sub Application_Startup Set olInsp = Outlook.Inspectors End Sub Private Sub myItem_Write(Cancel As Boolean) Dim oAtt As Outlook.Attachment Dim i As Integer If myItem.Attachments.Count > 0 Then For i = myItem.Attachments.Count To 1 Step -1 Set oAtt = myItem.Attachments.Item(i) oAtt.Delete Set oAtt = Nothing Next End If End Sub Private Sub olInsp_NewInspector(ByVal Inspector As Inspector) On Error GoTo err Set myInsp = Inspector Set myItem = myInsp.CurrentItem Exit Sub err: MsgBox err.Description End Sub Private Sub Application_Quit Set myItem = Nothing Set myInsp = Nothing Set olInsp = Nothing End Sub  On the File menu, click Save. On the File menu, click Close and Return to Microsoft Office Outlook. On the File menu, click Exit to exit Outlook.</li> Start Outlook.</li> On the Tools menu, click Options.</li> Click the Mail Format tab.</li> In the Compose in this message format box, click Rich Text.</li> Click to select the Use Microsoft Office Word 2003 to edit e-mail messages check box, and then click to select the Use Microsoft Office Word 2003 to read Rich Text e-mail messages check box.</li> Click OK.</li> On the File menu, point to New, and then click Mail Message.</li> Type an e-mail address in the To box, and then add an attachment to the message.</li> Click Send.</li> When the Mailbox Cleanup dialog box appears, click Close. Notice that the attachment still appears in the message body.</li> Click Send again. You receive the error message that is mentioned in the &quot;Symptoms&quot; section.</li></ol>

<div class="references_section">