我正尝试创建一个VBA宏,该电子邮件附件根据电子邮件地址保存到文件夹。例如,如果我通过[email protected]收到附件并附上电子邮件,我想将该附件保存到目录 \ server \ home \ joey ,或者如果我从[email protected]收到该附件,则附件应保存在 \ server \ home \ steve。将电子邮件附件保存到网络位置
最后,我想发送一个回复电子邮件与保存的文件的名称。我发现一些代码几乎可以做我想做的事情,但我很难修改它。这一切都是在Outlook 2010中完成的。这是迄今为止我所拥有的。任何帮助将不胜感激
Const mypath = "\\server\Home\joe\"
Sub save_to_v()
Dim objItem As Outlook.MailItem
Dim strPrompt As String, strname As String
Dim sreplace As String, mychar As Variant, strdate As String
Set objItem = Outlook.ActiveExplorer.Selection.item(1)
If objItem.Class = olMail Then
If objItem.Subject <> vbNullString Then
strname = objItem.Subject
Else
strname = "No_Subject"
End If
strdate = objItem.ReceivedTime
sreplace = "_"
For Each mychar In Array("/", "\", ":", "?", Chr(34), "<", ">", "|")
strname = Replace(strname, mychar, sreplace)
strdate = Replace(strdate, mychar, sreplace)
Next mychar
strPrompt = "Are you sure you want to save the item?"
If MsgBox(strPrompt, vbYesNo + vbQuestion) = vbYes Then
objItem.SaveAs mypath & strname & "--" & strdate & ".msg", olMSG
Else
MsgBox "You chose not to save."
End If
End If
End Sub
这个作品感谢您的帮助。 – 2012-04-23 09:56:00