0
我需要在Outlook中創建一個宏來將某些電子郵件重定向到特定文件夾。處理zip附件outlook vba腳本
我必須歧視加上10 MB附件,但條件是包含在zip中的文件應該被處理,並且如果未壓縮的內容大於10 MB,這些也應該考慮在內。
我想知道如何解壓縮文件檢查所有文件的大小,如果文件總大小大於10MB發送到一個文件夾,否則發送到另一個文件夾。
我需要在Outlook中創建一個宏來將某些電子郵件重定向到特定文件夾。處理zip附件outlook vba腳本
我必須歧視加上10 MB附件,但條件是包含在zip中的文件應該被處理,並且如果未壓縮的內容大於10 MB,這些也應該考慮在內。
我想知道如何解壓縮文件檢查所有文件的大小,如果文件總大小大於10MB發送到一個文件夾,否則發送到另一個文件夾。
Attachment類提供Size屬性,該屬性返回一個Long,指示附件的大小(以字節爲單位)。
要獲得未壓縮的大小,您需要將附加文件保存在磁盤上,然後提取內容。 Attachment類的SaveAsFile方法將附件保存到指定的路徑。
Sub SaveAttachment()
Dim myInspector As Outlook.Inspector
Dim myItem As Outlook.MailItem
Dim myAttachments As Outlook.Attachments
Set myInspector = Application.ActiveInspector
If Not TypeName(myInspector) = "Nothing" Then
If TypeName(myInspector.CurrentItem) = "MailItem" Then
Set myItem = myInspector.CurrentItem
Set myAttachments = myItem.Attachments
'Prompt the user for confirmation
Dim strPrompt As String
strPrompt = "Are you sure you want to save the first attachment in the current item to the Documents folder? If a file with the same name already exists in the destination folder, it will be overwritten with this copy of the file."
If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
myAttachments.Item(1).SaveAsFile Environ("HOMEPATH") & "\My Documents\" & _
myAttachments.Item(1).DisplayName
End If
Else
MsgBox "The item is of the wrong type."
End If
End If
End Sub
請參閱Unzip file(s) with the default Windows zip program (VBA)的代碼來解壓文件。
1.你的問題是什麼; 2.你有什麼嘗試? –