2016-05-31 76 views
2

我正在編寫一個宏,目的是在電子郵件上運行,當前正在編輯從正在編輯的電子郵件中刪除附件

我面對的問題是,我無法刪除附件。我得到80030002 error

這裏是我的代碼

Set myItem = ActiveInspector.CurrentItem 
c = myItem.Attachments.Count 
For i = c To 1 Step -1 
    Set myAttachment = myItem.Attachments.Item(i) 
    If myAttachment.Type = OlAttachmentType.olByValue Then 
     myItem.Attachments.Remove (i) 
    End If 
Next 

運行此代碼,工作刪除附件後手動結果在Outlook崩潰。

我的問題是:如何從當前正在編輯的電子郵件中刪除附件?

Microsoft Office標準版2010

+0

錯誤代碼是STG_E_FILENOTFOUND。當你打開一個MSG文件時會發生這種情況嗎? –

+0

我沒有打開任何文件。我點擊「撰寫新電子郵件」,將一些文件放入新的空電子郵件中,然後運行上面的腳本。而已!有任何想法嗎?謝謝! –

回答

1

嘗試,而不是執行以下操作:

Set myItem = Application.ActiveInspector.CurrentItem 
set myAttachments = myItem.Attachments 
c = myAttachments.Count 
For i = c To 1 Step -1 
    Set myAttachment = myAttachments.Item(i) 
    If myAttachment.Type = OlAttachmentType.olByValue Then 
     myAttachment.Delete 
    End If 
Next 
+0

謝謝,但不幸的是,相同的結果:(任何其他的想法? –