下面的代码(我从几个来源中提取)现在的工作原理是,当我收到主题行中包含特定单词的电子邮件时,它会触发运行下面的脚本.
然后,此代码保留主题行,将邮件正文和转发文本添加到预期收件人.
但是,如果我收到的电子邮件有附件,则代码不再转发任何内容.我需要它来转发通过电子邮件发送给我的附件(仅使用代码将文本添加到电子邮件正文中,否则我只会设置规则).
代码如下:
Sub ForwardEmail(item As Outlook.MailItem)
Dim oExplorer As Outlook.Explorer
Dim oMail As MailItem
Set oExplorer = Application.ActiveExplorer
On Error GoTo Release
If oExplorer.Selection.item(1).Class = olMail Then
Set oMail = item.Forward
oMail.Subject = oMail.Subject
oMail.HTMLBody = "Have a nice day." & vbCrLf & oMail.HTMLBody
oMail.Recipients.Add "email address here"
oMail.Save
oMail.Send
End If
Release:
Set oMail = Nothing
Set oExplorer = Nothing
End Sub
Run Code Online (Sandbox Code Playgroud) 有人可以告诉我如何在此代码中添加"抄送收件人"吗?"收件人"和代码都按预期工作.感谢您的时间.
Sub ForwardEmail(item As Outlook.MailItem)
' Dim oExplorer As Outlook.Explorer
Dim oMail As MailItem
' Set oExplorer = Application.ActiveExplorer
On Error GoTo Release
' If oExplorer.Selection.item(1).Class = olMail Then
Set oMail = item.Forward
oMail.Subject = oMail.Subject
oMail.HTMLBody = "Have a nice day." & vbCrLf & oMail.HTMLBody
oMail.Recipients.Add "email address here"
' oMail.Save
oMail.Send
' End If
Release:
Set oMail = Nothing
' Set oExplorer = Nothing
End Sub
Run Code Online (Sandbox Code Playgroud)