0
我試圖保存電子郵件中的Excel(.xlsm)文件。我通過另一封電子郵件收到此郵件。保存電子郵件附件的附件
我想將上述.xlsm文件下載到共享驅動器。查找多個在線論壇和MSDN幫助我寫了以下代碼:
當我運行此代碼時,我沒有收到任何錯誤。也沒有保存任何文件。
Public Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim msgAtt As Outlook.Attachment
Dim saveFolder As String
' a to i are dummy names and have been replaced with correct folder path in real code
saveFolder = "\\a\b\c\d\e\f\g\h\i"
For Each objAtt In itm.Attachments
If InStr(objAtt.DisplayName, ".msg") Then
For Each msgAtt In itm.Attachments
If InStr(msgAtt.DisplayName, ".xlsm") Then
msgAtt.SaveAsFile saveFolder & "\" & msgAtt.DisplayName
End If
Next
Set msgAtt = Nothing
End If
Next
Set objAtt = Nothing
End Sub
的可能的複製[VBA代碼保存附件(Excel文件)從Outlook的電子郵件,這是另一個電子郵件內作爲附件(https://stackoverflow.com/questions/7890612/vba -code-to-save-an-attachment-excel-from-an-an-an-outlook-email-that-ins-ins) – niton
@niton我同意所期望的結果是一樣的,但在這種情況下面臨的特定問題是不同於那種情況 –