【发布时间】:2017-12-18 08:14:17
【问题描述】:
我有一个宏,可以将收件箱中电子邮件的所有附件保存到指定目录。但是,我想以电子邮件主题作为文件名保存附件。
这是我的第一个宏,也是第一次查看 VBA,因此非常感谢任何指针。
Private Sub Outlook_VBA_Save_Attachment()
''Variable declarions
Dim ns As NameSpace
Dim inb As Folder
Dim itm As MailItem
Dim atch As Attachment
''Variables Initialization
Set ns = Outlook.GetNamespace("MAPI")
Set inb = ns.GetDefaultFolder(olFolderInbox)
File_Path = "H:\Notes\"
''Loop Thru Each Mail Item
For Each itm In inb.Items
''Loop Thru Each Attachment
For Each atch In itm.Attachments
If atch.Type = olByValue Then
atch.SaveAsFile File_Path & atch.FileName
End If
Next atch
Next itm
'''''Notify the Termination of Process
MsgBox "Attachments Extracted to: " & File_Path
End Sub
【问题讨论】: