D
Dawn
Hi, with the help of searching this forum (thanks, this place is amazing!) I
figured out a script that would forward a specified email when a rule finds
emails that meet certain criteria. It works really well, but I still have
two questions.
1) I am not sure I've saved the script in an appropriate location. I
really like this script and imagine I will be able to use variants of it for
a number of situations, so I want to be sure I'm saving it appropriately to
do so. The location I picked was based on a post, but it may have just been
telling a person where to save a script to test it temporarily?
In the Visual Basic editor, I have the Projects explorer window open, which
gave me a folder called Microsoft Office Outlook Objects. In this folder is
something called ThisOutlookSession. If I click this, a VB window is opened,
and I have my code in there. I am hoping if I put in another similar sub
into the same window, I will then be able to pick it to be used in another
rule.
2) the script works great, except that it would be even better if it
retained the body of the email that fired the rule. This code produces an
email that retains just the subject line, but the body of the email is blank
except for my new text. Code is below. Thanks in advance for any help!
Sub RunAScriptRuleRoutine(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim msg As Outlook.MailItem
Dim fwd As Outlook.MailItem
strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set msg = olNS.GetItemFromID(strID)
Set fwd = msg.Forward
With fwd
.To = "(e-mail address removed)"
.Subject = fwd.Subject & " -- MY TEXT HERE"
.HTMLBody = "Here is my email message."
.Send
End With
Set msg = Nothing
Set olNS = Nothing
End Sub
figured out a script that would forward a specified email when a rule finds
emails that meet certain criteria. It works really well, but I still have
two questions.
1) I am not sure I've saved the script in an appropriate location. I
really like this script and imagine I will be able to use variants of it for
a number of situations, so I want to be sure I'm saving it appropriately to
do so. The location I picked was based on a post, but it may have just been
telling a person where to save a script to test it temporarily?
In the Visual Basic editor, I have the Projects explorer window open, which
gave me a folder called Microsoft Office Outlook Objects. In this folder is
something called ThisOutlookSession. If I click this, a VB window is opened,
and I have my code in there. I am hoping if I put in another similar sub
into the same window, I will then be able to pick it to be used in another
rule.
2) the script works great, except that it would be even better if it
retained the body of the email that fired the rule. This code produces an
email that retains just the subject line, but the body of the email is blank
except for my new text. Code is below. Thanks in advance for any help!
Sub RunAScriptRuleRoutine(MyMail As MailItem)
Dim strID As String
Dim olNS As Outlook.NameSpace
Dim msg As Outlook.MailItem
Dim fwd As Outlook.MailItem
strID = MyMail.EntryID
Set olNS = Application.GetNamespace("MAPI")
Set msg = olNS.GetItemFromID(strID)
Set fwd = msg.Forward
With fwd
.To = "(e-mail address removed)"
.Subject = fwd.Subject & " -- MY TEXT HERE"
.HTMLBody = "Here is my email message."
.Send
End With
Set msg = Nothing
Set olNS = Nothing
End Sub