我目前正在接收有关Outlook的每周报告,我需要打开并保存在特定文件夹中。我成功地重命名了文件并将其传输到所需的文件。
但是,文件格式与附加到电子邮件的文件不同,当我没有在日期末尾添加日期格式或类型“.2016”时,它被注册为类型“文件”我放一个文件。在记事本中打开时,信息不可读
以下是我目前使用的代码:
Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
Dim dateFormatdateFormat = Format(Now, "dd.mm.yyyy")
saveFolder = "C:\Users\mypathtotheattachment"
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "\" & "thenewnameofmyattachment" & ".csv"
Next
End Sub
欢迎任何帮助,我扫描了整个地方以获取任何信息,但我被卡住了......
谢谢!
答案 0 :(得分:0)
这是你想要做的吗?
Option Explicit
Public Sub SaveAtmtToDisk(Item As Outlook.MailItem)
Dim Atmt As Outlook.Attachment
Dim SavePath As String
Dim FileName As String
' // Saved Location
SavePath = "C:\temp\"
' // 05 24 2016 Antoine.csv
FileName = Format(Now, "DD MM YYYY") & " Antoine.csv"
For Each Atmt In Item.Attachments
Atmt.SaveAsFile SavePath & "\" & FileName
Next
Set Atmt = Nothing
End Sub
在Outlook 2010上测试