我[试图]学习如何在Outlook中编写脚本,以便在电子邮件中设置某个类别时:
我的目标是标记包含类别的电子邮件,并将电子邮件转发至我们的售票系统。
我找到的样品并不是真的好运。
我尝试过的示例(URL)(复制的代码和更新的相关字段):
答案 0 :(得分:0)
- 使用"附加主题PROJ = 5"
醇>
MailItem.Subject Property
返回表示Outlook项目的字符串。读/写。
Item.Subject = "PROJ=5" & Item.Subject
- 使用约10行文字附加正文
醇>
实施例
Dim olBody As String
olBody = "<HTML><BODY><P>Append the Body with about 10 lines of text</P>" & vbNewLine & vbNewLine & _
"<P>Append the Body with about 10 lines of text</P></HTML></BODY>" & vbNewLine
olForward.HTMLBody = olBody & vbCrLf & olForward.HTMLBody
- 发送/转发电子邮件
醇>
实施例
'//
Set olForward = Item.Forward
'// add Recipent
olForward.Recipients.Add "email@domain.com"
'// Send or your use .Dispaly
olForward.Send
运行脚本规则
要使用Rule Wizard,您的宏必须具有预期参数:
实施例
Public Sub ItemForward(Item As Outlook.MailItem)
End Sub
Helpful article in MSDN Outlook 2010 VBA
Outlook 2010 VBA
请确保您的参考设置为运行操作脚本(工具&gt;参考)
Option Explicit
'// Run Action Script
Public Sub ItemForward(Item As Outlook.MailItem)
Dim olApp As Outlook.Application
Dim olForward As MailItem
Dim olBody As String
Set olApp = CreateObject("Outlook.Application")
'// Append the Subject
Item.Subject = "PROJ=5 " & Item.Subject
Item.Save
Set olForward = Item.Forward
'// add Recipent
olForward.Recipients.Add "Test@mail.com"
olBody = "<HTML><BODY><P>Append the Body with about 10 lines of text</P>" & vbNewLine & vbNewLine & _
"<P>Append the Body with about 10 lines of text</P>" & vbNewLine & _
"<P>Append the Body with about 10 lines of text</P>" & vbNewLine & _
"<P>Append the Body with about 10 lines of text</P>" & vbNewLine & _
"<P>Append the Body with about 10 lines of text</P>" & vbNewLine & _
"<P>Append the Body with about 10 lines of text</P>" & vbNewLine & _
"<P>Append the Body with about 10 lines of text</P>" & vbNewLine & _
"<P>Append the Body with about 10 lines of text</P>" & vbNewLine & _
"<P>Append the Body with about 10 lines of text</P>" & vbNewLine & _
"<P>Append the Body with about 10 lines of text</P></HTML></BODY>" & vbNewLine
'// Forward Email
olForward.HTMLBody = olBody & vbCrLf & olForward.HTMLBody
'// Send or your use .Dispaly
olForward.Send
Set olApp = Nothing
Set olForward = Nothing
End Sub