|
可以 的
我刚刚玩完
- Sub NewMailSaveAttachemnets()
- '// outlook 所指定的邮件 自动答复指定的人
- '//内容固定的
- Dim mail As Outlook.MailItem
- Dim Fso As Object
- Dim myOlExp As Outlook.Explorer '//outlook
- Dim myOlSel As Outlook.Selection '//outlook所在选择项
- Set Fso = CreateObject("Scripting.FileSystemObject") '//FSO文件对象
- Dim MsgTxt As String
- Dim x As Integer
- Dim Folder As String
- Dim reg As String
- Dim MyFileName As String
- Set myOlExp = Application.ActiveExplorer '//指向对象
- Set myOlSel = myOlExp.Selection
- Dim vItem As Object
- reg = "\d+"
- For x = 1 To myOlSel.Count
- If myOlSel.Item(x).Attachments.Count > 0 Then
- For i = 1 To myOlSel.Item(x).Attachments.Count
- Set vItem = myOlSel.Item(x).Attachments(i)
- MyFileName = vItem.Subject
- Debug.Print MyFileName
- If InStr(MyFileName, "单") = 0 Then
- vItem.SaveAsFile "D:" & vItem.FileName '//保存到另外一个文件夹
- Else
- '//判断是否包含该月份的文件夹,有则保存在文件夹 ,无则创建文件
- Folder = "D:\PDF文件\2013" & Val(Mid(getRegtoString(reg, MyFileName), 5, 2)) & "月份"
- If Not Fso.FolderExists("Folder") Then
- Fso.CreateFolder (Folder)
- End If
- vItem.SaveAsFile Folder & "" & vItem.FileName
- End If
- Next i
- End If
- Next x
- End Sub
复制代码
|
|