1

我正在使用以下代码将电子邮件照片保存到特定文件夹:

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] 标记中。这可能吗 ?

4

2 回答 2

2

路径中有一个额外的“\”。

试试 objAtt.SaveAsFile saveFolder & itm.Subject & ".JPG"

或 saveFolder = "C:\Temp"

于 2013-10-23T02:40:41.453 回答
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
于 2013-10-29T12:09:52.483 回答