![]() |
Script help - retain forwarded email body & location of script
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 = " .Subject = fwd.Subject & " -- MY TEXT HERE" .HTMLBody = "Here is my email message." .Send End With Set msg = Nothing Set olNS = Nothing End Sub |
Script help - retain forwarded email body & location of script
1) That's a fine place. You can also add a new module to hold just your rule
scripts if you prefer. You can copy and paste the one you have to create the next one, changing the name of the procedure, of course. 2) This statement replaces the existing body with the text on the right side of the equals sign: .HTMLBody = "Here is my email message." Take it out, and the forward message will be unchanged. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Dawn" wrote in message ... 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 = " .Subject = fwd.Subject & " -- MY TEXT HERE" .HTMLBody = "Here is my email message." .Send End With Set msg = Nothing Set olNS = Nothing End Sub |
Script help - retain forwarded email body & location of script
Thanks Sue! Can you think of a way to both of a way to retain the original
body of the email, along with my new text that I'm trying to put in? I can always just go find the original email by using the subject line, but it would be great if I could save that step. Similar to how the subject line is retained, along with my additional text. Would something like this work? ..HTMLBody = "Here is my email message." & fwd.Body Cheers, Dawn "Sue Mosher [MVP]" wrote: 1) That's a fine place. You can also add a new module to hold just your rule scripts if you prefer. You can copy and paste the one you have to create the next one, changing the name of the procedure, of course. 2) This statement replaces the existing body with the text on the right side of the equals sign: .HTMLBody = "Here is my email message." Take it out, and the forward message will be unchanged. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Dawn" wrote in message ... 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 = " .Subject = fwd.Subject & " -- MY TEXT HERE" .HTMLBody = "Here is my email message." .Send End With Set msg = Nothing Set olNS = Nothing End Sub |
Script help - retain forwarded email body & location of script
Sorry, it wasn't clear to me from your earlier posts that you needed to add
information to the forwarded message. If you don't care about formatting, you can use code like what you propose. If you want to retain the full formatting of the item, you need to work with fwd.HTMLBody not fwd.Body, but you can't just use simple concatenation. You would need to insert the new text inside the HTMLBody content, with proper HTML tagging (as in a web page); that just takes some text parsing. You may have other options as well, depending on your Outlook version and the email editor. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Dawn" wrote in message ... Thanks Sue! Can you think of a way to both of a way to retain the original body of the email, along with my new text that I'm trying to put in? I can always just go find the original email by using the subject line, but it would be great if I could save that step. Similar to how the subject line is retained, along with my additional text. Would something like this work? .HTMLBody = "Here is my email message." & fwd.Body Cheers, Dawn "Sue Mosher [MVP]" wrote: 1) That's a fine place. You can also add a new module to hold just your rule scripts if you prefer. You can copy and paste the one you have to create the next one, changing the name of the procedure, of course. 2) This statement replaces the existing body with the text on the right side of the equals sign: .HTMLBody = "Here is my email message." Take it out, and the forward message will be unchanged. "Dawn" wrote in message ... 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 = " .Subject = fwd.Subject & " -- MY TEXT HERE" .HTMLBody = "Here is my email message." .Send End With Set msg = Nothing Set olNS = Nothing End Sub |
Script help - retain forwarded email body & location of script
Thanks! I don't know how to do HTML tagging, can you point me in right
direction? (and sorry if I'm asking for the sun moon and stars, I really don't know if what I'm asking is complicated or not!) The end result I'm looking for is an email, that would be as if I had hit the "forward" button in outlook, then typed my message ("my text here") and hit send. I'm wanting my additional text to appear as the first thing in the email string. "Sue Mosher [MVP]" wrote: Sorry, it wasn't clear to me from your earlier posts that you needed to add information to the forwarded message. If you don't care about formatting, you can use code like what you propose. If you want to retain the full formatting of the item, you need to work with fwd.HTMLBody not fwd.Body, but you can't just use simple concatenation. You would need to insert the new text inside the HTMLBody content, with proper HTML tagging (as in a web page); that just takes some text parsing. You may have other options as well, depending on your Outlook version and the email editor. -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Dawn" wrote in message ... Thanks Sue! Can you think of a way to both of a way to retain the original body of the email, along with my new text that I'm trying to put in? I can always just go find the original email by using the subject line, but it would be great if I could save that step. Similar to how the subject line is retained, along with my additional text. Would something like this work? .HTMLBody = "Here is my email message." & fwd.Body Cheers, Dawn "Sue Mosher [MVP]" wrote: 1) That's a fine place. You can also add a new module to hold just your rule scripts if you prefer. You can copy and paste the one you have to create the next one, changing the name of the procedure, of course. 2) This statement replaces the existing body with the text on the right side of the equals sign: .HTMLBody = "Here is my email message." Take it out, and the forward message will be unchanged. "Dawn" wrote in message ... 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 = " .Subject = fwd.Subject & " -- MY TEXT HERE" .HTMLBody = "Here is my email message." .Send End With Set msg = Nothing Set olNS = Nothing End Sub |
Script help - retain forwarded email body & location of script
Sorry, but I'm not equipped to do an HTML tutorial; there are plenty of
those on the web. You'll get a good start if you just look at the source of any HTML-format message. In the meantime, if you don't care about formatting, you can just use this: .Body = "Here is my email message." & vbCrLf & fwd.Body -- Sue Mosher, Outlook MVP Author of Microsoft Outlook 2007 Programming: Jumpstart for Power Users and Administrators http://www.outlookcode.com/article.aspx?id=54 "Dawn" wrote in message ... Thanks! I don't know how to do HTML tagging, can you point me in right direction? (and sorry if I'm asking for the sun moon and stars, I really don't know if what I'm asking is complicated or not!) The end result I'm looking for is an email, that would be as if I had hit the "forward" button in outlook, then typed my message ("my text here") and hit send. I'm wanting my additional text to appear as the first thing in the email string. "Sue Mosher [MVP]" wrote: Sorry, it wasn't clear to me from your earlier posts that you needed to add information to the forwarded message. If you don't care about formatting, you can use code like what you propose. If you want to retain the full formatting of the item, you need to work with fwd.HTMLBody not fwd.Body, but you can't just use simple concatenation. You would need to insert the new text inside the HTMLBody content, with proper HTML tagging (as in a web page); that just takes some text parsing. You may have other options as well, depending on your Outlook version and the email editor. "Dawn" wrote in message ... Thanks Sue! Can you think of a way to both of a way to retain the original body of the email, along with my new text that I'm trying to put in? I can always just go find the original email by using the subject line, but it would be great if I could save that step. Similar to how the subject line is retained, along with my additional text. Would something like this work? .HTMLBody = "Here is my email message." & fwd.Body Cheers, Dawn "Sue Mosher [MVP]" wrote: 1) That's a fine place. You can also add a new module to hold just your rule scripts if you prefer. You can copy and paste the one you have to create the next one, changing the name of the procedure, of course. 2) This statement replaces the existing body with the text on the right side of the equals sign: .HTMLBody = "Here is my email message." Take it out, and the forward message will be unchanged. "Dawn" wrote in message ... 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 = " .Subject = fwd.Subject & " -- MY TEXT HERE" .HTMLBody = "Here is my email message." .Send End With Set msg = Nothing Set olNS = Nothing End Sub |
All times are GMT +1. The time now is 12:40 PM. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2006 OutlookBanter.com