Article ID: 285989
Article Last Modified on 2/12/2007
APPLIES TO
- Microsoft Outlook 97 Standard Edition
This article was previously published under Q285989
SYMPTOMS
You use the Remove method to programmatically remove an attachment from an item, but the attachment is not actually deleted from the Attachments collection.
CAUSE
The Remove method was not fully implemented in the Outlook object model.
WORKAROUND
Instead of using the Remove method, use the Delete method of the Attachment object.
STATUS
Microsoft has confirmed that this is a problem in the Microsoft products that are listed at the beginning of this article.
MORE INFORMATION
Steps to Reproduce the Problem
- Open an existing item that has one or more attachments.
Run the following Outlook automation code from Microsoft Visual Basic, or Visual Basic for Applications in another Microsoft Office program, making sure to reference the Microsoft Outlook 8.0 Object Library:
Sub RemoveAttachments() Dim app As Outlook.Application Dim itm As Object Dim atts As Attachments Set app = New Outlook.Application Set itm = app.ActiveInspector.CurrentItem Set atts = itm.Attachments While atts.Count > 0 atts.Remove 1 Wend itm.Save Set atts = Nothing Set itm = Nothing Set app = Nothing End Sub
- Note that the attachments appear to be deleted.
- Close, and then reopen the item.
Result: The attachments are still there.
REFERENCES
For additional information about creating solutions with Microsoft Outlook, click the article numbers below to view the articles in the Microsoft Knowledge Base:
166368 OL97: Resources for Custom Forms and Programming
170783 OL97: Questions About Customizing or Programming Outlook
Additional query words: OutSol OutSol97
Keywords: KB285989