一、前言
二、代码
Public Sub SaveAttach(Item As Outlook.MailItem)'MsgBox (Item.Subject)ReceivedTime = Format(Item.ReceivedTime, "yyyymmdd")FilePath = "d:\WorkFiles\" + Format(Item.ReceivedTime, "yyyy") + "\" + Format(Item.ReceivedTime, "mm") + "\" + ReceivedTime + "-秎ンン-" + Item.Subject'MsgBox (FilePath)Dim hasPathhasPath = dir(FilePath, vbDirectory)If hasPath = "" ThenMkDir (FilePath)ElseFilePath = FilePath + "_" + Format(Now, "hhmmss")MkDir (FilePath)End If'MsgBox FilePath'MkDir FilePathSaveAttachment Item, FilePath + "\"MsgBox "玂秎ン" + Item.Subject + "" + "いン"End Sub'保存附件' path为保存路径,condition为附件名匹配条件Private Sub SaveAttachment(ByVal Item As Object, path$, Optional condition$ = "*")Dim olAtt As AttachmentDim i As IntegerIf Item.Attachments.Count > 0 ThenFor i = 1 To Item.Attachments.CountSet olAtt = Item.Attachments(i)' save the attachmentIf olAtt.FileName Like condition ThenolAtt.SaveAsFile path & olAtt.FileNameEnd IfNextEnd IfSet olAtt = NothingEnd Sub
三、调用
通过添加规则对所有收到的携带附件的邮件运行以上脚本即可。
如果你喜欢我的文章,欢迎来给我买咖啡,而且还可以买不止一杯。

捐赠支持作者!
