希望有人可以为我揭示这一点。
我编写了一个脚本,该脚本应该保存带有特定标题的电子邮件附件(我在outlook的规则部分指定了这部分,还是应该写入脚本?)
由于某种原因,它不起作用。以下是我的脚本: -
Public Sub saveAttachmentTtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "C:/LocationOfFolderToSaveTo"
For Each objAtt In itm.Attachments
objAtt.SaveAsFile saveFolder & "\" & objAtt.DisplayName
Set objAtt = Nothing
Next
End Sub
任何人都可以看到我出错的地方。
答案 0 :(得分:1)
saveFolder =" C:/ LocationOfFolderToSaveTo"
应该是 saveFolder = "C:\LocationOfFolderToSaveTo\"
要按主题行指定 - 尝试添加IF function
以检查是否符合指定条件
If olItem.Subject = "Subject line here" Then
Option Explicit
Public Sub Save_Attachment(olItem As Outlook.MailItem)
Dim olAttch As Outlook.Attachment
Dim sPath As String
'sPath = Environ("USERPROFILE") & "\Documents\"
sPath = "C:\Temp\"
For Each olAttch In olItem.Attachments
If olItem.Subject = "0m3r" Then
olAttch.SaveAsFile sPath & "\" & olAttch.DisplayName
End If
Next
Set olAttch = Nothing
End Sub