我正在使用以下代码将电子邮件照片保存到特定文件夹:
Private Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim saveFolder As String
saveFolder = "C:\Temp\"
For Each objAtt In itm.Attachments
If objAtt.FileName <> "image001.gif" Then
objAtt.SaveAsFile saveFolder & "\" & itm.Subject & ".JPG"
End If
Set objAtt = Nothing
Next
End Sub
然而,我无法让它真正发挥作用。我已经尝试将它保存在ThisOutlookSession中,并作为附加到规则的模块,但没有保存任何内容。
我还想创建另一个脚本来将电子邮件的注释保存到文本文件中,其中特定文本将写入正文中的[COMMENT]标记。这可能吗?
答案 0 :(得分:2)
路径中有一个额外的“\”。
尝试objAtt.SaveAsFile saveFolder&amp; itm.Subject&amp; “.JPG”
或saveFolder =“C:\ Temp”
答案 1 :(得分:1)
这是我开始工作的代码:
Sub saveAttachtoDisk(itm As Outlook.MailItem)
Dim objAtt As Outlook.Attachment
Dim dateFormat
dateFormat = Format(Now, "yyyy-mm-dd")
'Message subject should be the meter serial number i.e.K11TB00864
Dim subject
subject = Trim(itm.subject)
Dim saveFolder As String
saveFolder = "C:\Temp\Photo"
For Each objAtt In itm.Attachments
If objAtt.FileName <> "image001.gif" Then
objAtt.SaveAsFile saveFolder & "\" & itm.subject & " " & dateFormat & ".jpg"
End If
Set objAtt = Nothing
Next
End Sub