我从不同来源获取代码并将它们组合在一起。
我想手动对电子邮件进行分类,手动选择要发送的电子邮件,然后根据类别自动将所选电子邮件转发给适当的参与者。
我一直在使用两个来源来尝试完成这项工作:
Forward Email with its attachment in Outlook 2010
这是我整理的内容。当我运行它时,什么也没发生:
Sub ForwardMSREmail()
Dim oExplorer As Outlook.Explorer
Dim oMail As MailItem
Set oExplorer = Application.ActiveExplorer
On Error GoTo Release
If item.Class = olMail Then
Set oMail = item.Forward
oMail.Subject = oMail.Subject
oMail.HTMLBody = "Have a nice day." & vbCrLf & oMail.HTMLBody
Dim objMail As Outlook.MailItem
If InStr(objMail.Categories, "Joshua") > 0 Then
oMail.Recipients.Add "email address"
oMail.Save
oMail.Send
End If
End If
Release:
Set oMail = Nothing
Set oExplorer = Nothing
End Sub