• Outlook User
  • New Outlook app
  • Outlook.com
  • Outlook Mac
  • Outlook & iCloud
  • Developer
  • Microsoft 365 Admin
    • Common Problems
    • Microsoft 365
    • Outlook BCM
    • Utilities & Addins

Send a New Message when a Message Arrives

Slipstick Systems

› Outlook › Rules, Filters & Views › Send a New Message when a Message Arrives

Last reviewed on March 11, 2021     208 Comments

A security update disabled the Run a script option in the rules wizard in Outlook 2010 and all newer Outlook versions. See Run-a-Script Rules Missing in Outlook for more information and the registry key to fix restore it.

How to use a Run a Script rule to have Microsoft Outlook automatically send a new email message using a template, to a new email addresses when a message meeting specific conditions arrives. I also have a version of the script that sends a new message with the body of the message that triggered the rule to another person. (To avoid including the Reply header in the body).

To use, open the VBA Editor and paste the code into ThisOutlookSession. Create a Run a Script rule, selecting this rule.

When you create the template, do not include a signature. Outlook will add the signature when the message is sent. To test the rule without sending messages, change objMsg = Send to ojbMsg = Display. This will open the message form instead of sending it.

New message using a template

Sub SendNew(Item As Outlook.MailItem)
 
Dim objMsg As MailItem
Set objMsg = Application.CreateItemFromTemplate("C:\path\to\test-rule.oft")

' If the address you want to send to is not saved in the template, 
' set the addresses here
'objMsg.Recipients.Add "alias@domain.com"

objMsg.Send

End Sub

 

To reply to the sender using a template

This script could be used for an Out of Office style reply. Using this method will send a reply with every message that meets the condition of the rule.

Sub SendNew(Item As Outlook.MailItem)
 
Dim objMsg As MailItem
Set objMsg = Application.CreateItemFromTemplate("C:\path\to\test-rule.oft")

objMsg.Recipients.Add Item.SenderEmailAddress

' Copy the original message subject 
objMsg.Subject = "Attn: " & Item.Subject

objMsg.Send

End Sub

To Forward the message body to another address

This version of the script sends a new message containing the body of the received message. (If you want to forward the complete message, use the Forward rule.)

Hyperlinks links will be "opened". To avoid this, and if you don't mind converting the messages to HTML, you can use objMsg.HTMLBody = Item.HTMLBody instead (it works with plain text and RTF messages), or create an If Then statement to check for incoming body types and use the correct format. As always, test it with messages to yourself or using objMsg.Display before using it to send messages to others.

Sub SendNew(Item As Outlook.MailItem)
 
Dim objMsg As MailItem
Set objMsg = Application.CreateItem(olMailItem)

objMsg.Body = Item.Body
objMsg.Subject = "FW: " & Item.Subject
objMsg.Recipients.Add "alias@domain.com"

objMsg.Send

End Sub

More Information

More Run a Script Samples:
  • Autoaccept a Meeting Request using Rules
  • Automatically Add a Category to Accepted Meetings
  • Blocking Mail From New Top-Level Domains
  • Convert RTF Messages to Plain Text Format
  • Create a rule to delete mail after a number of days
  • Create a Task from an Email using a Rule
  • Create an Outlook Appointment from a Message
  • Create Appointment From Email Automatically
  • Delegates, Meeting Requests, and Rules
  • Delete attachments from messages
  • Forward meeting details to another address
  • How to Change the Font used for Outlook's RSS Feeds
  • How to Process Mail After Business Hours
  • Keep Canceled Meetings on Outlook's Calendar
  • Macro to Print Outlook email attachments as they arrive
  • Move messages CC'd to an address
  • Open All Hyperlinks in an Outlook Email Message
  • Outlook AutoReplies: One Script, Many Responses
  • Outlook's Rules and Alerts: Run a Script
  • Process messages received on a day of the week
  • Read Outlook Messages using Plain Text
  • Receive a Reminder When a Message Doesn't Arrive?
  • Run a script rule: Autoreply using a template
  • Run a script rule: Reply to a message
  • Run a Script Rule: Send a New Message when a Message Arrives
  • Run Rules Now using a Macro
  • Run-a-Script Rules Missing in Outlook
  • Save all incoming messages to the hard drive
  • Save and Rename Outlook Email Attachments
  • Save Attachments to the Hard Drive
  • Save Outlook Email as a PDF
  • Sort messages by Sender domain
  • Talking Reminders
  • To create a rule with wildcards
  • Use a Macro to Copy Data in an Email to Excel
  • Use a Rule to delete older messages as new ones arrive
  • Use a run a script rule to mark messages read
  • Use VBA to move messages with attachments
Send a New Message when a Message Arrives was last modified: March 11th, 2021 by Diane Poremsky
Post Views: 920

Related Posts:

  • Run a script rule: Autoreply using a template
  • Use this macro to send an attachment to email addresses in the To line
    VBA: No attachments to CC'd recipients
  • A simple run a rule script marks Outlook messages read when the messag
    Use a run a script rule to mark messages read
  • Run a script rule: Reply to a message

About Diane Poremsky

A Microsoft Outlook Most Valuable Professional (MVP) since 1999, Diane is the author of several books, including Outlook 2013 Absolute Beginners Book. She also created video training CDs and online training classes for Microsoft Outlook. You can find her helping people online in Outlook Forums as well as in the Microsoft Answers and TechNet forums.

Comments

  1. Kim says

    May 17, 2024 at 2:36 pm

    Hi Diane,
    I'm trying to find a way to send a new email (not forward, redirect, reply) or text when a new email arrives. Basically Sender A sends email to Recipient A. When Recipient A receives the email I then want a new email or SMS created that simply states "New email has arrived" and sent to Recipient B. The web rule to send text doesn't work for us since we must append special characters to the Subject or the message gets dropped. Any help is appreciated. Thanks.

    Reply
    • Diane Poremsky says

      May 17, 2024 at 4:03 pm

      Are you using classic Outlook? If yes, you can do this using a macro in a rule. If you use webmail, you cannot do this.

      This should work in a rule -

      Sub SendNew(Item As Outlook.MailItem)

      Dim objMsg As MailItem
      Set objMsg = Application.CreateItem(olMailItem)

      objMsg.Body = "New email has arrived"
      objMsg.Subject = Item.Subject & "special characters"
      objMsg.Recipients.Add "RecipientB@domain.com"

      objMsg.Send

      End Sub

      Reply
  2. Dave says

    May 5, 2022 at 10:29 am

    Hello.
    On outlook 2010, I am trying to run different scrips from VBA modules based on different words in the subject of the email received. It seems that I cannot create more then one script and choose then in rules. Surely there must be way to do such action. Thanks in advance

    Reply
    • Diane Poremsky says

      May 5, 2022 at 11:09 pm

      You can use multiple scripts - one per rule though - unless you use a "stub" macro in the rule and hand off to other macros. You need to use If statements in the macro to do different things based on the words found.

      Reply
      • Dave says

        May 19, 2022 at 8:47 pm

        Hi Diane
        Thanks so much for assistance and apologies for late reply. Dont have access to internet all the time.
        Goal is to forward emails without 'FW' in subject line and forwarding header in the body of the email. I am using your code from above for that and it works great. The problem is as said earlier, based on the words in the subject line and sender, to trigger different rules and scripts with different receiver emails adress. I cannot workout how to solve that.
        Once again thanks for assistance and this blog.

      • Diane Poremsky says

        May 19, 2022 at 11:23 pm

        You would either use more rules or if statements within a macro. Multiple rules can use the same script - so if action is the same, separate rules might work better.

  3. Naveed says

    October 21, 2018 at 4:14 am

    Hi, I receive some emails with attachments everyday which can be opened only from my computer (sender has given me a digital certificate). I need to forward all these mails to one of my colleague. When I set a rule for autoforward, he receives the mail, but is not able to view the contents or attachments. But when I open the mail in my computer and forward, it works fine. Is there a way to autoforward these mails properly?

    Reply
  4. Santiago Correal says

    March 30, 2018 at 1:27 am

    Hi,
    I'm trying to foward an email automaticly when i receive it. However, I need to Bcc it to a list of contacts that are listed at the beginning of the email an then erase this contact list from the email before sending it..
    Is that possible?

    Reply
    • Diane Poremsky says

      April 3, 2018 at 1:05 am

      Yes, it would be possible. Is the BCC list identified as such? There are different ways to grabbing the list... and the best way depends on how the list is entered.

      Reply
  5. Terence says

    July 30, 2017 at 9:27 pm

    Hi,

    I am trying to send a new message, when a new message arrives, as per the code above.

    And it works beautifully, thank you very much.

    but i have 2 problems
    1) the message i receive, includes images, and the ones i sent using the script, only have placeholders in the original images places.
    2) the message body i sent is long, and my outlook signature appears beside (like in a table) the original body.

    Can anyone help me with this 2 small issues please?

    Reply
    • Diane Poremsky says

      August 2, 2017 at 12:51 am

      #1 is difficult to fix - the embedded images are identified by a CID, forwarding breaks it. Forwarding it as attachment would work, but then it's an attachment...

      #2: Which script are you using? You may need to add some line breaks or something to add space after the signature.

      Reply
  6. Kristy Thompson says

    July 18, 2017 at 1:11 pm

    Hello, I am new to this as well, and I am needing to forward the original email with any attachments, and include a simple instruction statement with it. Such as "process on account xxxx".

    Reply
    • Diane Poremsky says

      July 18, 2017 at 10:51 pm

      The macro at https://www.slipstick.com/outlook/rules/run-script-rule-reply-message/ shows how to do it - change.reply to .forward to use it to forward mail.

      Reply
  7. Jeremy Johnons says

    July 3, 2017 at 3:15 pm

    Is it possible to auto send an email to an email address within the original email. For instance, someone fills out an online fors, I get an emailed notification telling me their infor from the form. Can I set up an automatic email that sends to the email address within the notification email?

    Reply
    • Diane Poremsky says

      July 4, 2017 at 2:26 pm

      Yes, if you use a macro to grab the address. See https://www.slipstick.com/developer/run-a-script-rule-autoreply-using-a-template/ for a sample.

      Reply
  8. anisha says

    February 8, 2017 at 6:36 pm

    hi can I also send the outlook emails dynamically to excel/word or CSV. In detail Whenever I receive a mail in a particular folder the email should be also exported to an external document like excel/csv/word real time

    Reply
    • Diane Poremsky says

      May 30, 2017 at 1:10 pm

      You can. This shows how to send to excel - the macro at the end is an items add macro and can be tweaked to work in a run a script rule.
      https://www.slipstick.com/developer/code-samples/macro-export-outlook-fields-excel/

      Reply
  9. Bob says

    December 5, 2016 at 7:02 pm

    I am trying to create a modified "reply with template" script. In short, I will be CC'ed on a email from "Sender" to "Recipient". I would like to reply ONLY to "Recipient" with a template that I have created. Is that possible? If not, then as a backup, I could reply all to both "Recipient" and "Sender", if that is an option.

    Thank you.

    Reply
    • Diane Poremsky says

      February 6, 2017 at 12:41 am

      it is possible - you'd start a new message using the template and copy the recipient address from the original message.
      https://www.slipstick.com/outlook/rules/send-a-new-message-when-a-message-arrives/#oof - use item.to as the to address in the new message.

      Reply
  10. Outlook User says

    November 4, 2016 at 6:18 pm

    Is there a way to automatically send another email, based on a template, to the same email address the original email was sent to? Example: original email was sent to example@example.com. Once the original email leaves the Outbox, a second email, based on a template, automatically gets sent to the same email address, example@example.com.

    Thank you and look forward to your suggestion.

    Reply
    • Diane Poremsky says

      November 6, 2016 at 8:30 am

      Should be able to do that using a macro. I don't have any that do exactly this though.

      Reply
  11. Leo G. says

    September 14, 2016 at 10:14 am

    Will this be the same setup for shared email accounts using the "To reply to the sender using a template" ? I have a user that monitors several shared accounts and she wants replies sent from each account.

    Reply
    • Diane Poremsky says

      February 6, 2017 at 12:38 am

      She would need to add the accounts to her mailbox as separate accounts to use rules or use an itemadd macro to watch the inboxes. But if she is the one replying, as long as she has send as permission on the shared account, replies should be from the shared account.

      Reply
  12. David Dozier says

    September 1, 2016 at 12:54 pm

    Thanks for this, it is a great tip. I have tried to set it up so that an email is generated to my phone via text; however, I am getting a syntax error when testing it. Here is the code (without the actual phone number):

    Sub SendNew(Item As Outlook.MailItem)

    Dim objMsg As MailItem
    Set objMsg.Recipients.Add "813#######@vtext.com"

    objMsg.Send

    End Sub

    What am I doing wrong?

    Reply
    • Diane Poremsky says

      September 1, 2016 at 4:45 pm

      Remove Set - it's not needed in that line.
      objMsg.Recipients.Add "813#######@vtext.com"

      Reply
  13. John says

    June 9, 2016 at 4:08 am

    Hi for the "To Forward the message body to another address"
    If i want to forward the email with attachment, what is the code?

    Reply
    • Diane Poremsky says

      August 23, 2016 at 11:48 am

      You need to save the attachment then add it back to the new message. In this case, i would probably copy the original message body and subject line and do a "normal" forward, then replace the body and subject.

      This article has a copyattachment function you can use: - https://www.slipstick.com/outlook/email/reply-replyall-attachments/
      use this line to copy the attachments using the function. Add it after oMsg is set but before it's sent.
      CopyAttachments Item, oMsg

      Reply
  14. Alan K. says

    May 20, 2016 at 4:40 pm

    Is there a way to forward e-mail to multiple people as they come in. For example, I have a main account sales@mycompany.com, I want to forward the first message that arrive to one of my sale representative, then the second message to a second sales representative and so on and so forth. Then when it reaches my last sales representative, it keeps forwarding to the first one. It's a little bit confusing, but I hope one of you would help me on that.

    Reply
    • Diane Poremsky says

      August 23, 2016 at 11:36 am

      Sorry I missed this earlier - the macro at https://www.slipstick.com/developer/code-samples/use-macro-assign-messages-shared-mailbox/ would work (with a little tweaking to forward instead of set categories). The case statements would have the email addresses and the lines that add the category and save it would be changed to
      set oForward = item.forward
      oforward.to = strCat
      oforward.send
      Err.Clear

      Reply
  15. Kristen says

    May 10, 2016 at 9:51 pm

    how do I find the appropriate path for my test rule? "C:\path\to\test-rule.oft") Mine is not located there. Thanks

    Reply
    • Diane Poremsky says

      May 10, 2016 at 10:14 pm

      Did you save your template in the default location for templates? Repeat the steps to save a message as a template and get the path from the Save dialog. (You don't need to save a new template, just need the path. :)) It should be at C:\Users\%username%\AppData\Roaming\Microsoft\Templates or paste the shortcut in the address bar of Windows Explorer: %appdata%\microsoft\templates

      Reply
      • Kristen says

        May 10, 2016 at 11:08 pm

        That fixed it thank you. I didn't understand I had to save the template first. Thanks!

  16. Vikas says

    February 3, 2016 at 3:51 am

    I am new in VBA. I am trying to write code that send mail to specific mail id when I receive the mail with same subject. Like If i received the mail with subject HELLO then i want it automatically goes to xyz@mail.com mail id for all mail with subject HELLO

    Reply
    • Diane Poremsky says

      February 3, 2016 at 11:00 pm

      Do you want to forward the message you received or send a new one? The last script on this page (To Forward the message body to another address) will send the received message body to a new address.

      You'll need to create a rule that contains the conditions you want to look for (like subject is Hello) then select the script you added to the VBA editor.

      Reply
      • Shalini Banerjee says

        May 26, 2016 at 9:47 am

        Hi,

        I am very new with VBA and am trying to do as the third option, where a mail is forwarded to intended parties. I need to add a message over the existing one and also want outlook to send replies at a given span of time.i.e, from 12:00 AM - 9:00 AM EST.
        Could that work?

      • Diane Poremsky says

        May 26, 2016 at 10:11 am

        it is possible - you'd use .body = "my message" & vbcrlf & item.body
        i have samples that forward mail based on the time at https://www.slipstick.com/developer/process-messages-received-day-week/

  17. Meera says

    August 24, 2015 at 6:04 am

    I am new to VB script.

    I am trying to write code that reads Outlook email periodically,and finds out whether we have received any new emails from a particular email ID. If Found, need to search for severity of the message(condition check), in the email body. If that matches a certain number,need to compose an email and send it to partuclar email ID again. What is the best possible way this can be done? Meaning which programing language can accomplish this easily? I am currently trying with VBScript. I am new to this. How easily this can be done using VB script?

    Thanks,

    Reply
  18. daniel says

    August 12, 2015 at 4:34 am

    hi diane,

    i have a question, how do i set the alignment of the body to rtl ?

    Reply
    • Diane Poremsky says

      August 13, 2015 at 1:15 am

      RTL isn't exposed in the object model, but if you are writing the HTML using code, using this should work -

      text goes here

      Reply
  19. seb says

    July 16, 2015 at 11:30 am

    OK. I think I need a script that starts manually, checks the mails of a specific folder, sends and moves them to a subfolder. Advice?

    Reply
  20. seb says

    July 16, 2015 at 11:02 am

    Thanks, it seems to work with objMsg.CC = Item.CC

    I have another noob question: the script only work when outlook is open, right?

    How to deal with messages i received when outlook is closed? sorry if i miss something...

    Reply
    • Diane Poremsky says

      July 16, 2015 at 11:08 am

      Correct, it only runs when outlook is open. Unfortunately there is no way to run it if outlook isn't open - you'd need something on the server or a standalone utility that could ping the mailbox.

      Reply
  21. seb says

    July 15, 2015 at 10:43 am

    Hi,

    I receive an email from a generic address, with the address of a person in CC .

    I would like to transfer the email by adding a model answer, ONLY to the person in CC.

    how to do that?

    thanks.

    Reply
    • Diane Poremsky says

      July 16, 2015 at 1:18 am

      Are you replying with an answer or using a template? Assuming it's the only name in the CC field, use objMsg.to = item.cc or objMsg.Recipients.Add item.cc

      Reply
  22. Anonymous says

    May 3, 2015 at 1:32 pm

    No - when I say crash I don't mean Outlook shuts down or the computer freezes, I just mean the rule fails and it won't work again until I go in and check off the box in the rules again.

    Reply
  23. Anonymous says

    May 3, 2015 at 7:19 am

    Got the macro to work, but it still crashes periodically. Thanks though

    Reply
    • Diane Poremsky says

      May 3, 2015 at 10:02 am

      it shouldn't cause it to crash. Does it crash at all if you disable the rule? (I'm thinking something else is causing it to crash.)

      Reply
  24. Anonymous says

    April 21, 2015 at 1:43 pm

    What are the steps to add a second macro?

    Reply
    • Diane Poremsky says

      April 22, 2015 at 9:22 pm

      Add the itemsend macro (the second macro to ThisOutlookSession. It gets the addresses in the CC field and cc's the message. If you wanted to send all messages to a specific address, change objMsg.CC = Item.CC to objMsg.CC = "email@address.com". if you want it to apply to all messages, you'll need to move the end if up under Next i.

      Reply
  25. Stephen M says

    April 20, 2015 at 9:05 pm

    Hello Diane
    I would like to change the subject of an autoBCC rule i found
    Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Dim objRecip As Recipient
    Dim strMsg As String
    Dim res As Integer
    Dim strBcc As String
    On Error Resume Next

    ' #### USER OPTIONS ####
    ' address for Bcc -- must be SMTP address or resolvable
    ' to a name in the address book
    strBcc = "SomeEmailAddress@domain.com"

    Set objRecip = Item.Recipients.Add(strBcc)
    objRecip.Type = olBCC
    If Not objRecip.Resolve Then
    strMsg = "Could not resolve the Bcc recipient. " & _
    "Do you want still to send the message?"
    res = MsgBox(strMsg, vbYesNo + vbDefaultButton1, _
    "Could Not Resolve Bcc Recipient")
    If res = vbNo Then
    Cancel = True
    End If
    End If

    Set objRecip = Nothing
    End Sub

    how would change the subject of this rule?
    thank you

    Reply
    • Diane Poremsky says

      April 21, 2015 at 12:36 am

      You can't change the subject of the message that is autoBCC'd - the macro adds the address to the BCC field before sending. If you wanted to send a copy of the message to an address and change the subject, you'd need to use a macro similar to this one: https://www.slipstick.com/developer/code-samples/no-attachments-to-cc-recipients/ - where you copy the message on send.

      Reply
  26. Tana says

    March 25, 2015 at 4:58 pm

    Ok I have a general mailbox to which users submit meeting agenda items. In addition, I use this email to respond with questions, follow-up, & clarifications. This is a business email & we have an exchange server.

    From what I understand if I use a Rule, it only runs when Outlook is open and running.

    If I use Automatic Replies, it only sends one reply per sender.

    What I want is a auto-reply acknowledging receipt of submission, so only one reply per user per subject.

    Example: If bob@xyz.com sends in an email with subject line "Minutes for approval". I want him to get one autoreply. If I email bob asking for clarification and he replies to my email I do not want him to get the autoreply (assuming the subject line remains the same).

    Also if bob@xyz.com sends another email, but with subject line "Board appointment", I want him to get a separate autoreply.

    Every rule I see would work ok if bob only sent one email, but when he sends multiple with multiple subjects...that's where I need help...

    Reply
    • Diane Poremsky says

      March 27, 2015 at 3:00 pm

      You can do this using vba but, like rules, it will only run when outlook is open. You'd filter for messages beginning with RE: or FW: then send a reply to the remaining.

      Reply
  27. Zachary Bass says

    March 17, 2015 at 9:42 pm

    Works great. Thank you very much. Similarly I set the myForward.Subject to Item.Subject to get rid of the "Fwd: " in the subject.

    Item.Body = ""
    Item.Save
    Set myForward = Item.Forward
    With myForward
    .Body = Item.Body
    .Subject = Item.Subject
    End With

    Reply
  28. Zachary Bass says

    March 16, 2015 at 6:33 pm

    HI Diane: I've added a rule along with your code sample below to ThisOutlookSession in order to forward an e-mail with attachment but I would also like to remove the four lines below that are added to a forwarded message. The idea is remove these lines so that the e-mail appears as new and not forwarded. The lines are not part of the body and I'm not clear how to delete. Thanks for any help.

    From: johndoe@xyzcompany.com
    Sent: Monday, March 16, 2015 2:34 PM
    To: jeff@123company.com
    Subject: Weekly Test Report

    '// Code sample
    Sub TestForward(item As Outlook.MailItem)
    Dim myForward As Object

    item.Subject = "Weekly Test Report"
    item.Save

    Set myForward = item.Forward
    myForward.Recipients.Add "joeblow@comcast.net"

    myForward.Send

    End Sub

    Reply
    • Diane Poremsky says

      March 16, 2015 at 9:43 pm

      Removing the lines is hard - but you could use myforward.body = item.body instead.

      Reply
  29. wdp says

    March 12, 2015 at 1:48 pm

    Diane et al-
    Lets say I want to include the date/time the original email message was received in the subject of the message that gets forwarded.
    What is the "item" for that?

    Currently I am using the following in the subject line:
    objMsg.Subject = Item.Sender & Item.Subject

    Which gives me the sender and subject but I'd like to include the time/date as well.
    Thanks,

    wdp

    Reply
    • Diane Poremsky says

      March 27, 2015 at 2:52 pm

      Try item.receivedtime

      Reply
  30. Anonymous says

    March 10, 2015 at 4:10 pm

    Another question - ever since I added my macro months ago I will intermittently (maybe once per day) get the error popup " "Rules In Error, The Operation Failed" and the macro doesn't work. I have generally just closed the error message, and gone into Manage Rules & Alerts and re-checked the box next to my rule which fixes the problem, but it is annoying. Any idea why this would be happening or how to fix it?

    Reply
    • Diane Poremsky says

      March 27, 2015 at 2:50 pm

      Is this the macro that is filing? Is it being triggered on meetings, receipts, or other non-mail mail?

      Reply
    • Anonymous says

      March 27, 2015 at 2:53 pm

      Yes it is related to the macro because when the error message appears it will stop working. I don't get read receipts, and I rarely get meetings, but it is definitely triggered on regular email.

      Reply
      • Diane Poremsky says

        March 27, 2015 at 5:06 pm

        The only thing I am aware of that can cause problems in rules is if you receive a lot of mail fast - the rule can fail to trigger. This doesn't normally cause it to be disabled as a failure, but it's possible if the script is busy, it could cause the rule to be marked a failure.

        One possible fix is to move the meat of the script into a second script. The script the rule uses keeps any If statements you might use to increase filtering then hands off to the script that actually does the work. I found this helps to prevent failures on one macro i use that processes a lot of mail.

    • Anonymous says

      March 27, 2015 at 5:10 pm

      Here is the script - how would I split into a second script as you suggest? It already seems pretty basic:

      Sub SendNew(Item As Outlook.MailItem)

      Dim objMsg As MailItem
      Set objMsg = Application.CreateItem(olMailItem)

      objMsg.Body = Item.SenderEmailAddress
      objMsg.Subject = Item.Sender
      objMsg.Recipients.Add "EMAILCENSORED@EMAILPROVIDER.COM"

      objMsg.DeleteAfterSubmit = True

      objMsg.Send

      End Sub

      Reply
      • Diane Poremsky says

        March 28, 2015 at 10:59 am

        At the very basic, this should work. If you need to filter using an If then statement, you'll do it in the sendnew macro before handing it off to the sendmail macro.

        Sub SendNew(Item As Outlook.MailItem)

        sendmail item
        End Sub

        Private Sub SendMail(Item As Outlook.MailItem)
        Dim objMsg As MailItem
        Set objMsg = Application.CreateItem(olMailItem)
        objMsg.Body = Item.SenderEmailAddress
        objMsg.Subject = Item.Sender
        objMsg.Recipients.Add "EMAILCENSORED@EMAILPROVIDER.COM"
        objMsg.DeleteAfterSubmit = True
        objMsg.Send
        End Sub

    • Anonymous says

      March 30, 2015 at 4:02 am

      Thanks - so can i just add those 3 lines at the top of my current macro, or are you saying I have to create a separate project in VBA for these new lines?

      Reply
      • Diane Poremsky says

        April 21, 2015 at 12:14 am

        You'll add this macro:
        Sub SendNew(Item As Outlook.MailItem)
        sendmail item
        End Sub

        This macro calls the Sendmail macro and hands the processing off to it, leaving it free to process the next message.

  31. Anonymous says

    March 10, 2015 at 3:12 pm

    Diane - I tried to follow your instructions to make a certificate using selfcert https://www.slipstick.com/developer/how-to-use-outlooks-vba-editor/#selfcert
    However, now I can't get the macros to run at all. When I restart Outlook it says "An error occurred while attempting to verify the VBA project's signature. Macros will be disabled." How can I remove the certificate/signature and go back to how it was working fine before? Thanks

    Reply
    • Anonymous says

      March 10, 2015 at 3:42 pm

      OK apparently I was missing the step where you have to save before closing VBA. Once I saved in VBA, then closed, then closed Outlook, and clicked yes when asked to save again, it worked. Also, I didn't realize you could always "Trust" (by clicking the left button on the popup window before allowing the macro) it so you wouldn't have to click "enable macro" every time (middle button on that popup window) after restarting Outlook, so that is nice that it seems to just stay active now. Now my problem is I can't find the Macro in the Macro list when I am trying to add it to the toolbar/ribbon using your instructions: https://www.slipstick.com/developer/how-to-use-outlooks-vba-editor/

      Reply
      • Diane Poremsky says

        March 10, 2015 at 5:18 pm

        Run a script rules won't be the macro list since it can't be run manually. You would need ot edit the macro or use a stub to call it, if you wanted to use it in a script and call it manually.

        You can use this stub to run a macro from a button and also in a script. Replace macro-name with the name of the macro. This works on the selected message.

        Public Sub RunManaully()
        Dim objItem
        Set objItem = Application.ActiveExplorer.Selection.Item(1)
        macro-name objItem
        End Sub

    • Diane Poremsky says

      March 10, 2015 at 6:14 pm

      In the VB editor, go into tools, digital signature and remove the signature. click save in the VB Editor then close Outlook and click Save again, if asked.

      Reply
  32. wdp says

    March 9, 2015 at 10:46 pm

    Diane- After creating the self cert as described above, I realized I never closed outlook.
    Upon re-open, I ran the rule and it worked!
    Thank you so very much for your input/help on this.
    Walt

    Reply
  33. wdp says

    March 9, 2015 at 8:09 am

    If I open the VBA editor and search for digital signature it sys:
    Certificate name: [No certificate]
    Sign as
    Certificate name: [No certificate]

    This script is connected to my work email account and I'm wondering if somehow Admin has removed my ability to fwd incoming messages? That would explain why a couple dozen worked and then suddenly it stopped?

    wdp

    Reply
    • Diane Poremsky says

      March 9, 2015 at 10:03 pm

      What is the macro security to set? If it's set for signed macros only, did you make a certificate using selfcert?
      https://www.slipstick.com/developer/how-to-use-outlooks-vba-editor/#selfcert

      Reply
  34. wdp says

    March 7, 2015 at 4:23 pm

    Diane et al-

    I created a script similar to the forward email - although instead of forwarding email body, it just forwards the name of the sender as the body. This worked great for 1 day - forwarding ~20 emails from Outlook 2010 to another email address perfectly.
    Today, I changed the email address where the forwards are sent too and Outlook seems to have stopped running the rule/script. The computer was never logged/turned-off. Any idea why the rule would stop working (I assume this is at the rule level because I am not seeing anything in the sent box to indicate the rule/script was run)?

    wdp

    Reply
    • Diane Poremsky says

      March 9, 2015 at 1:17 am

      Did you sign the original macro using a digital signature? If so, you need to remove the signature and re-sign it after editing it.

      Reply
  35. Moh says

    March 4, 2015 at 7:12 am

    Hi All,

    Can anyone help with a script i have written to create and send a new email to a target recipient. My intention is to evaluate the incoming message subject then create a new message with the original subject, body and most importantly attachment. I've used the forwarding example above as a basis but not seeing any activity.

    The script is as follows. Thanks!

    Public Sub fwdReport(Item As Outlook.MailItem)

    Dim objMsg As MailItem

    If Item.Subject = "z" Then

    Set objMsg = Application.CreateItem(olMailItem)

    objMsg.Body = Item.Body
    objMsg.Subject = Item.Subject
    objMsg.Attachments = Item.Attachments

    objMsg.Recipients.Add "RECIPIENT'S EMAIL"

    objMsg.Send

    End If

    End Sub

    Reply
    • Diane Poremsky says

      March 9, 2015 at 10:01 pm

      The rule that checks the subject calls the macro when a match is found, so you don't need this line (or the end if):
      If Item.Subject = "z" Then

      the rest should work.

      Reply
  36. M Saumure says

    February 19, 2015 at 9:47 am

    thank you for this!!

    Reply
  37. DAVID NORDEL says

    February 12, 2015 at 7:59 pm

    Hi Diane,
    I am attempting to write a script that will forward part of the body of a message up to a certain string of characters, while maintaining the formating for pictures and text. I am trying to forward a newsletter to an outlook contact group, and I am unsure which function to call to copy the message body. I believe the pictures are embedded, but I am not exactly sure. I have yet to even get to the point where I can add in code to cut-off the body as I am still trying to just get the whole message to properly forward. My code is as follows:

    Sub SendNew(Item As Outlook.MailItem)

    Dim objMsg As MailItem
    Set objMsg = Application.CreateItem(olMailItem)

    objMsg.Body = Item.Body
    CopyAttachments objMsg, Item
    objMsg.Subject = Item.Subject
    objMsg.Recipients.Add ("COI Test Group")

    objMsg.Send

    End Sub

    Sub CopyAttachments(objSourceItem, objTargetItem)
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolder
    strPath = fldTemp.Path & "\"
    For Each objAtt In objSourceItem.Attachments
    strFile = strPath & objAtt.FileName
    objAtt.SaveAsFile strFile
    objTargetItem.Attachments.Add strFile, , , objAtt.DisplayName
    fso.DeleteFile strFile
    Next

    Set fldTemp = Nothing
    Set fso = Nothing
    End Sub

    This script currently forwards the message without formatting or pictures, but includes the hyperlinks to the pictures. HELP! PLEASE!!!

    Thank you for your time and consideration, and I look forward to hearing form you soon.

    Reply
    • Diane Poremsky says

      February 12, 2015 at 8:34 pm

      Forwarding embedded pictures is difficult - they are attached then embedded in the code using a CID code. Do the images stay embedded if you forward the message? If so, it might be better to forward and remove the header.

      Try using objMsg.HTMLBody = Item.HTMLBody

      Reply
    • DAVID NORDEL says

      February 13, 2015 at 5:38 pm

      Thank you for the quick response Diane. I did, in fact, try using objMsg.HTMLBody = Item.HTMLBody without any luck. And the images do stay embedded when forwarding. I will try forwarding and removing the header. Thanks again!

      Reply
  38. Fabio says

    January 8, 2015 at 6:50 am

    Hi Diane,
    I just migrated from Lotus notes to Outlook 2010 and previously I had a rule that every message I received I would get a full copy on another email address. This meant that in the receiving inbox I could search by sender as it was showing exactly the same template as on my lotus note emails. This is different from forwarding a received message where in the address box I will have my forwarding address. I hope it is clear, and I wonder if it is possible at all with a script....

    Many thanks for your time.

    Fabio

    Reply
  39. Joe says

    December 27, 2014 at 10:05 am

    Hi Diane

    I copied your script 'forward message body to another address'. And created a rule to run script from any incoming email, excluding calendar invitations (in the rule). It worked twice. Then I received a calendar invite, and it didn't forward (as planned). However, the script doesn't work for normal emails anymore. Any advise.

    Reply
    • Diane Poremsky says

      December 28, 2014 at 11:54 pm

      Is the rule disabled? Is VBA addin disabled? Was the macro security settings changed?

      Reply
  40. Lance Hames says

    December 9, 2014 at 4:34 pm

    Diane,

    I am trying to send an email draft when a particular email arrives. Where should I look to start for this? Is it something that can be done with this script?

    Thanks,
    Lance

    Reply
    • Diane Poremsky says

      December 9, 2014 at 11:31 pm

      It would be easier to save the draft as a template and reply with the template. That can be done using either with a rule directly or using a run a script rule.

      Reply
      • Lance Hames says

        December 10, 2014 at 1:41 am

        How would I go about doing that? I couldn't quite figure out where to start. I'm at like ground zero with Outlook and VBA

      • Diane Poremsky says

        January 7, 2015 at 1:45 am

        Create the message then use File, Save as and select template. You can save it to Documents or anywhere you want, just note where it is saved. Then you would use the template macro on this page to reply to them.

  41. Lance Hames says

    December 8, 2014 at 11:57 pm

    I am looking for a solution to send a particular draft containing unique data to a customer after the notification that their invoice has been paid comes in from PayPal. Do you have any idea where I should start?

    Reply
  42. Dheeraj Poojari says

    November 5, 2014 at 9:24 am

    Diane, brilliant post on outlook automation. Quick query to the one above(linked images by Josh). Instead of forwarding, I am using "reply" to respond using a particular oft template. The images do not come up, and they show the linked images error. Can you help me with modifying the code? Below is the code.

    Sub ForwardGeneralNew()
    Dim oExplorer As Outlook.Explorer
    Dim oMail As MailItem
    Dim Item As MailItem
    Dim rMail As MailItem
    Set oExplorer = Application.ActiveExplorer
    Set oMail = oExplorer.Selection.Item(1).Forward
    oExplorer.Selection.Item(1).UnRead = False
    Set rMail = Application.CreateItemFromTemplate("C:\Macros\General.oft")
    On Error GoTo Release
    If oExplorer.Selection.Item(1).Class = olMail Then
    oMail.Subject = "Testing a auto reply"
    oMail.HTMLBody = rMail.HTMLBody _
    & vbCrLf & oMail.HTMLBody
    CopyAttachments oMail, Item
    oMail.Recipients.Add "x@y.com"
    oMail.Recipients.Item(1).Resolve
    If oMail.Recipients.Item(1).Resolved Then
    oMail.Display
    ' oMail.Save
    'oMail.Send
    oMail.UnRead = False
    Else
    MsgBox "Could not resolve " & oMail.Recipients.Item(1).Name
    End If
    Else
    MsgBox ("Not a mail item")
    End If
    Release:
    Set oMail = Nothing
    Set oExplorer = Nothing
    End Sub

    Reply
    • Diane Poremsky says

      November 23, 2014 at 11:44 pm

      Are the images are embedded in the template?

      Reply
  43. Ry says

    October 10, 2014 at 2:19 pm

    How feasible is it to write a program to create rules in Outlook? I have a batch of rules I'd like to give to multiple users and would love to not have to create them for each person. The variables in the rules are almost the same for every user and could be tweaked to make it the same for every user as well.

    Reply
    • Diane Poremsky says

      October 12, 2014 at 10:29 pm

      You can create some rules using VBA - i have a basic sample that reads rules here - https://www.slipstick.com/outlook/rules/create-list-rules/ - to give you an idea about what is involved. Your script would need to create the rules obviously.

      Reply
  44. Ashleigh says

    September 19, 2014 at 2:07 pm

    Hi, I have used script to change the name of an email and auto forward it regularly. Is was wondering if there is a way i can ensure the person who receives it can not auto forward it?

    Reply
    • Diane Poremsky says

      September 19, 2014 at 6:45 pm

      No, you can't. Even things like signing it with a digital signature won't have much effect - the recipient can copy the text if they really want to share it.

      Reply
      • Ashleigh says

        September 20, 2014 at 10:01 am

        Ok, thanks! So the only way to select "do not autoforward" is manually each time through options-permissions-donotautoforward? If the recipient wants to copy the text I know i cant do much about that, but was hoping to make it harder for them to forward it automatically!

      • Ashleigh says

        September 20, 2014 at 1:00 pm

        Ok thanks! Just checking then, the only way to do this is manually by selecting options-permissions-donotforward? I know if soomeone wants to copy the text i cant really stop them, but just wanted to make it harder for them to forward it automatically!

      • Diane Poremsky says

        September 20, 2014 at 6:23 pm

        Correct. That may not prevent all recipients from forwarding it, but it is the only option.

      • Ashleigh says

        September 24, 2014 at 1:37 pm

        Thanks Diane, much appreciated. Just to confirm then, the only way to stop someone forwarding it easily is through options-permissions-do not forward. I know i cant stop anyone from copying the text and forwarding but was hoping to make it a bit harder!

      • Diane Poremsky says

        September 24, 2014 at 5:36 pm

        Correct. If you use IRM, it can block forwarding attachments, not sure about messages though. I discovered the other day that you don't need a corporate irm server to use it. You only need a non-free/non-isp address - microsoft calls it an organizational account - https://technet.microsoft.com/en-us/library/dn592127
        i set up an account for testing but haven't had a lot of time to use it.

  45. Josh Heo says

    August 7, 2014 at 11:01 am

    Hi, Thanks again for the help..
    Hmm.. I am still unable to see the picture after auto forwarding it to myself to test it...
    I tried to "click here to download pictures..." and still same "x"
    Anything else to try out?

    Thank you.

    Reply
    • Diane Poremsky says

      August 7, 2014 at 11:31 am

      Were the images attached in the original message or linked? If the macro doesn't add image attachments to the forward, then they are linked - and the link is messed up. Look at the source code of the original and forward message and see how the image is added and if there is anything different in the forward.

      Reply
      • Josh Heo says

        August 7, 2014 at 11:42 am

        I'm not sure if the image is attached or link in the original email.
        When I forward the original email manually, the picture shows as it should. Error only happens when I use the script to auto-forward the email.

        Only major difference I see is this.
        ------------------------------------------
        Original email source
        X-MS-Has-Attach: yes

        Script Forwarded Email source
        X-MS-Has-Attach:
        -------------------------------------------

      • Diane Poremsky says

        August 7, 2014 at 1:13 pm

        looks like the image is embedded and not linked properly in the copy.

      • Josh Heo says

        August 7, 2014 at 11:49 am

        Oh.. When I look at the email body's source code, it is whole lot different... not even sure where to begin..
        I'll try and let you know..
        Thank you so much!! feels like I'm getting there!

      • Josh Heo says

        August 7, 2014 at 12:02 pm

        Ok. Found the difference. There's a lot more code written in the original email where the pictures are inserted.

        Original email body source (I'm starting from where I see major difference)

        @list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:\F0A7;
        mso-level-tab-stop:4.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
        @list l1
        {mso-list-id:829977713;
        mso-list-template-ids:-1328494356;}
        @list l1:level1
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}
        @list l1:level2
        {mso-level-number-format:bullet;
        mso-level-text:\F0B7;
        mso-level-tab-stop:1.0in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Symbol;}

        AND SO ON.....
        =========================================
        Script auto forwarded Email body source

        @list l0:level9
        {mso-level-number-format:bullet;
        mso-level-text:;
        mso-level-tab-stop:4.5in;
        mso-level-number-position:left;
        text-indent:-.25in;
        mso-ansi-font-size:10.0pt;
        font-family:Wingdings;}
        @list l1
        {mso-list-id:1687898031;
        mso-list-template-ids:2114627028;}
        @list l2
        {mso-list-id:2091350142;
        mso-list-template-ids:-2020052588;}
        ol
        {margin-bottom:0in;}
        ul
        {margin-bottom:0in;}

        and it ends soon
        ==========================================
        I also see that in the

        original email,.
        mso-level-text:\F0B7;

        Where as Script Email is
        mso-level-text:;

      • Diane Poremsky says

        August 7, 2014 at 1:10 pm

        Images are missing, correct? You want to look for img tags.
        <img src="https://www.domain.com/s.png" alt="">

        They'll either begin with https:// (or just //) or cid:

      • Josh Heo says

        August 7, 2014 at 12:25 pm

        I ran and saw the source code again and it looks like I have it backwards.

        Script Email is
        mso-level-text:\F0B7;

        original email is
        mso-level-text:;

        Also, forwarded email source code is a lot longer...

        I am not sure if it makes any sense... confused..

      • Josh Heo says

        August 7, 2014 at 3:07 pm

        found the img tags...

        src="cid:image001.jpg@01CFB225.F6ED3AB0"

        Only issue is that both source is same for img tags....

      • Diane Poremsky says

        August 7, 2014 at 3:57 pm

        Wild guess: the GUID used with the cid (the part after the @) changes - oh, its in the header as a multipart mime. I'll see if there is a way to do it. You might need to use Forward instead of copying the body.

  46. Josh Heo says

    August 6, 2014 at 5:52 pm

    Sorry.. I am not sure if my previous question was uploaded.

    I cannot see pictures when I use this script to auto forward emails.
    I see "x" and "the linked image cannot be displayed"

    How can I correct it?

    Reply
    • Diane Poremsky says

      August 7, 2014 at 10:21 am

      Are you using the one to forward the message body (objMsg.Body = Item.Body)? If the images are attached/embedded, you also need to copy the attachments over.
      Add this line after the body line:
      CopyAttachments objMsg, Item

      and use this function:

      Sub CopyAttachments(objSourceItem, objTargetItem)
      Set fso = CreateObject("Scripting.FileSystemObject")
      Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolder
      strPath = fldTemp.Path & "\"
      For Each objAtt In objSourceItem.Attachments
      strFile = strPath & objAtt.FileName
      objAtt.SaveAsFile strFile
      objTargetItem.Attachments.Add strFile, , , objAtt.DisplayName
      fso.DeleteFile strFile
      Next

      Set fldTemp = Nothing
      Set fso = Nothing
      End Sub

      Reply
      • Josh Heo says

        August 7, 2014 at 10:25 am

        Hi, Thank you so much for helping!!
        So.. Like this?? I have no experience on this...

        Sub SendNew(Item As Outlook.MailItem)

        Dim objMsg As MailItem
        Set objMsg = Application.CreateItem(olMailItem)

        objMsg.HTMLBody = Item.HTMLBody
        CopyAttachments objMsg, Item

        Sub CopyAttachments(objSourceItem, objTargetItem)
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolder
        strPath = fldTemp.Path & "\"
        For Each objAtt In objSourceItem.Attachments
        strFile = strPath & objAtt.FileName
        objAtt.SaveAsFile strFile
        objTargetItem.Attachments.Add strFile, , , objAtt.DisplayName
        fso.DeleteFile strFile
        Next

        Set fldTemp = Nothing
        Set fso = Nothing

        objMsg.Subject = "FW: " & Item.Subject
        objMsg.Recipients.Add "junheo01@gmail.com"

        objMsg.Send

        End Sub

      • Diane Poremsky says

        August 7, 2014 at 10:34 am

        Close, the function is separate, added after the macro.

        Sub SendNew(Item As Outlook.MailItem)

        Dim objMsg As MailItem
        Set objMsg = Application.CreateItem(olMailItem)

        objMsg.HTMLBody = Item.HTMLBody
        CopyAttachments objMsg, Item
        objMsg.Subject = "FW: " & Item.Subject
        objMsg.Recipients.Add "junheo01@gmail.com"

        objMsg.Send

        End Sub

        Sub CopyAttachments(objSourceItem, objTargetItem)
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolder
        strPath = fldTemp.Path & "\"
        For Each objAtt In objSourceItem.Attachments
        strFile = strPath & objAtt.FileName
        objAtt.SaveAsFile strFile
        objTargetItem.Attachments.Add strFile, , , objAtt.DisplayName
        fso.DeleteFile strFile
        Next

        Set fldTemp = Nothing
        Set fso = Nothing
        End Sub

      • Jill Naus says

        September 5, 2014 at 8:51 pm

        I get an Object Required error at this line:

        objTargetItem.Attachments.Add strFile, , , objAtt.DisplayName

      • Diane Poremsky says

        September 8, 2014 at 12:03 am

        Are you using this macro? If you need the source and target emails, not the file.
        Sub CopyAttachments(objSourceItem, objTargetItem)

      • Jill Naus says

        September 8, 2014 at 4:15 am

        Thanks, Diane. I no longer get the error, but my forwarded emails still aren't showing their images. The images are included as attachments, but not showing in their proper place in the message body. This is the script I am using:

        Sub FwdAdminEmailtoPlanner()
        Dim adminaddress As String
        Dim objMail As Outlook.MailItem
        Dim objMsg As Outlook.MailItem
        Dim strbody As String
        Dim oldmsg As String
        Dim senderaddress As String
        Dim addresstype As Integer

        ' Set this variable as your helpdesk e-mail address
        adminaddress = "address@server.com"

        Set objItem = Application.ActiveWindow.Selection.Item(1)
        Set objMail = objItem.Forward

        'adds the senders e-mail address as the created by object for the ticket and appends the message body
        strbody = "Admin team,Please see below (and attached) for an admin request that was sent directly to a Planner. Will you please reach out to the customer and give them the correct contact information for future requests? Thank you."

        ' Sender E=mail Address
        senderaddress = objItem.SenderEmailAddress

        'Searches for @ in the email address to determine if it is an exchange user
        addresstype = InStr(senderaddress, "@")

        ' If the address is an Exchange DN use the Senders Name
        If addresstype = 0 Then
        senderaddress = objItem.SenderName
        End If

        Set objMsg = Application.CreateItem(olMailItem)

        objMsg.HTMLBody = strbody & objItem.Forward.HTMLBody
        If objItem.Attachments.Count > 0 Then
        Call CopyAttachments(objItem, objMsg)
        End If
        objMsg.To = adminaddress
        objMsg.Attachments.Add objItem, olEmbeddeditem
        objMsg.Subject = objItem.Subject

        objMsg.Display

        Set objItem = Nothing
        Set objMail = Nothing
        End Sub

        Sub CopyAttachments(objSourceItem, objTargetItem)
        Set fso = CreateObject("Scripting.FileSystemObject")
        Set fldTemp = fso.GetSpecialFolder(2) ' TemporaryFolder
        strPath = fldTemp.Path & "\"
        For Each objatt In objSourceItem.Attachments
        strFile = strPath & objatt.FileName
        objatt.SaveAsFile strFile
        objTargetItem.Attachments.Add strFile, , , objatt.DisplayName
        fso.DeleteFile strFile
        Next

        Set fldTemp = Nothing
        Set fso = Nothing
        End Sub

      • Diane Poremsky says

        September 8, 2014 at 10:31 pm

        When you forward, the CID code changes and outlook can't identify the when attachment belongs to which placeholder.

      • Jill Naus says

        September 11, 2014 at 12:18 am

        Is there a way to work around it?

      • Diane Poremsky says

        September 11, 2014 at 10:43 am

        What you need to do is remove the image from the new message then re-imbed it so a new CID is generated, but i don't have any code that does that.

        If the image properly displays when you click forward and send it, it should work to replace this objMsg.HTMLBody = strbody & objItem.Forward.HTMLBody with word code to insertbefore. The only problem with that code is that you need to display the message. The flash it creates is really annoying if you are trying to work.

      • Jill Naus says

        September 11, 2014 at 2:59 pm

        Worked like a charm, Diane! You are awesome!

  47. Ken Rogers says

    August 4, 2014 at 2:47 pm

    I have a custom form that users enter a URL in one field and then, with some VB scripting, the recipient can click on a separate button to launch the URL. This works great until the original recipient forwards the form. When forwarded, the VB scripting gets disabled so no links. Funny thing - I opened the forwarded form in my developer tab and ran from there and the links worked.

    Reply
    • Diane Poremsky says

      August 5, 2014 at 1:26 am

      1) It needs to be published or at least saved in the templates folder if you aren't using Exchange and have it in the org forms library.
      2) Outlook security has a setting to allow script in folders. File, Options, Trust Center, Email security

      Reply
      • Ken Rogers says

        August 5, 2014 at 7:18 am

        I should have said - each user has the form published in their personal forms library. My company doesn't support forms so I can't get access to the organizational library. And all the users can access the form, create one, and receive with no problem. It's just on forwarding when the script gets disabled.

      • Diane Poremsky says

        August 7, 2014 at 10:23 am

        I think the problem is that the forwarded copy is one-offed and scripts are disabled in one-off forms for security reasons.

  48. Anthony Parchmont says

    July 21, 2014 at 10:11 am

    Thank you, works like charm!

    Reply
    • Anthony Parchmont says

      October 20, 2014 at 4:47 pm

      Hi Diane, What can I do if I just want to forward only the attachments, but just specific file extension such .xls, .doc., .pdf. Other files like .png, .gif, .jpg should not get forwarded. The code below is what I used to forward only attachments, but it attaches all attachments.

      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)
      ' do stuff with msg, e.g.
      Set fwd = msg.Forward
      fwd.Body = ""
      fwd.To = "who@where.com; who2@where2.com"
      fwd.Send

      Set msg = Nothing
      Set fwd = Nothing
      Set olNS = Nothing
      End Sub

      Please help me with one.

      Reply
      • Diane Poremsky says

        October 20, 2014 at 5:42 pm

        with the other dim's
        Dim attCount As Long
        Dim strFile As String
        Dim sFileType As String

        Stick this in before the send:
        fwd.To = "who@where.com; who2@where2.com"
        attCount = fwd.Attachments.Count

        For i = attCount To 1 Step -1
        strFile = fwd.Attachments.Item(i).filename
        sFileType = LCase$(Right$(strFile, 4))

        Select Case sFileType
        ' file extensions you want to keep
        Case ".pdf", ".doc", "docx", "xlsx"
        ' do nothing
        Case Else
        ' delete all other attachments
        fwd.Attachments.Item(i).Delete
        End Select
        Next i
        fwd.Display ' .send

  49. Anthony Parchmont says

    July 19, 2014 at 11:47 am

    Hi Diane, In the “To Forward the message body to another address” How can I forward the original email as an attachment and add a custom static message body to say “ please see the attached message”

    I would be grateful for your help on this one.

    Reply
    • Diane Poremsky says

      July 20, 2014 at 7:58 am

      You add the text in the .body command and use .attachments add Item to add the message as an attachment.

      Because we're referring to objMsg a few times, using With/End with is better:
      with objMsg
      .Body = "my message " & vbcrlf & Item.Body
      .Subject = "FW: " & Item.Subject
      .attachments.add item
      .Recipients.Add "alias@domain.com"
      .Send
      end with

      Reply
  50. Michael Martin says

    June 30, 2014 at 3:34 am

    Diane, Thanks for your response. Appreicate if some one can develop this addin for me. what will it cost?

    Reply
  51. Michael Martin says

    June 27, 2014 at 11:32 am

    Diane, I would like to create a rule / script that can read two emails by the subject line and forward a mail to another email address.

    example: i recieve an email with subject line "Problem" at 9:00 am. I get another email in 30 minutes later with the subject line "Resolved".

    If i do not get in 30 mins the resolved email, i want to forward this problem email to another email address. how can i set this up by creating rules / scripts? please help

    Reply
    • Diane Poremsky says

      June 27, 2014 at 10:17 pm

      I'm not sure you can do this using rules, but you'd need to use windows timer, so it would be better in a com add in. I'll give it some more thought because its an interesting idea.

      Reply
  52. Kathy Oliver says

    June 20, 2014 at 3:13 pm

    If I use the script for the auto reply, will the auto reply work every time a new email is received by the same sender? We are looking for the auto reply to send every time an email is sent by the same sender while the rule is in place.

    Reply
    • Diane Poremsky says

      June 20, 2014 at 7:10 pm

      Yes, if you use a script for the reply, it will apply to every message from an address.

      Reply
  53. Nic Xiaoyu Qi says

    April 27, 2014 at 1:55 pm

    Hi,

    I am trying to make a macro to forward a email but include the selected email as an attachment.
    I've got everything to work apart from attaching the selected email as an attachment.

    Reply
    • Diane Poremsky says

      May 23, 2014 at 10:11 pm

      see the code sample near the bottpm f this page: https://www.slipstick.com/outlook/rules/create-task-email-rule/

      Reply
  54. Anonymous says

    April 25, 2014 at 1:18 pm

    Thanks. I figured it out. I am copying my code below in case it helps anyone else.

    Sub SendNew(Item As Outlook.MailItem)

    Dim objMsg As MailItem
    Set objMsg = Application.CreateItem(olMailItem)

    objMsg.Body = Item.SenderEmailAddress
    objMsg.Subject = Item.Sender
    objMsg.Recipients.Add "________@_____.com"

    objMsg.DeleteAfterSubmit = True

    objMsg.Send

    End Sub

    Reply
  55. Nasim rawat says

    April 15, 2014 at 11:10 pm

    yes i have also include attachment.

    Reply
  56. Anonymous says

    April 15, 2014 at 12:36 pm

    I figured out the problem in my previous question yesterday - the macro settings were too restrictive so it was blocking my script. Now I am wondering if there is a way to adjust the script to automatically delete the message from my sent mail?

    Reply
    • Diane Poremsky says

      April 16, 2014 at 12:55 am

      If you need to watch the sent folder, you'll have to use an itemadd or itemsend macro. The code sample here - https://www.slipstick.com/developer/code-samples/use-a-macro-to-move-imap-account-sent-items/ - should point you in the right direction. You'll use item.delete instead of the move stuff.

      Reply
  57. Anonymous says

    April 14, 2014 at 7:49 pm

    I was using a variation of your last example successfully several weeks ago, but for some reason when I tried to enable it again today I am not getting any notifications sent out. I just want an email sent to my personal email address with the name/email of the sender in the subject/body when new email arrives (I do not want the body/subject of the original email address sent to my personal email address due to security concerns). Here is the script. The top is my attempt at modifying yours. The bottom with all the ' marks was the one that worked great previously. Where I say _______@______.com is my personal email which I don't want to include on here. Thank you for your help!

    Sub SendNew(Item As Outlook.MailItem)

    Dim objMsg As MailItem
    Set objMsg = Application.CreateItem(olMailItem)

    objMsg.Body = Item.Sender
    objMsg.Subject = Item.SenderEmailAddress
    objMsg.Recipients.Add "_______@______.com"

    objMsg.Send

    End Sub
    'Sub SendRuleMail(objItem As Outlook.MailItem)
    ' Dim objMail
    ' Dim strMsg
    '
    ' 'Create a message object
    ' Set objOutlk = CreateObject("Outlook.Application")
    ' Set objMail = objOutlk.CreateItem(0)
    '
    ' 'Create a new message
    ' objMail.To = "___________@____.com"
    ' objMail.CC = "" 'Enter an address here To include a carbon copy; bcc is For blind carbon copy's
    '
    ' 'Set up Subject Line
    ' objMail.Subject = objItem.Sender
    '
    ' 'Add the body
    ' strMsg = objItem.Sender 'I used the subject of the new mail for the body
    ' objMail.Body = strMsg
    ' objMail.Send
    '
    ' 'Clean up
    ' Set objMail = Nothing
    ' Set strMsg = Nothing
    ' Set objOutlk = Nothing
    'End Sub

    Reply
  58. Nasim rawat says

    April 7, 2014 at 11:52 pm

    HI Diane,
    I want to auto forward email without adding previous sender or receiver,
    this is news email that send by sender on multiple user ids when i forward it it add all email ids in message body, some emails have attachments. I am beginner in VBA.

    Reply
    • Diane Poremsky says

      April 8, 2014 at 10:00 pm

      You'll want to use the last one, Forward the message body to another address. This copies the message body to a new message. Do you also need to include the attachments?

      Reply
  59. Russell Brown says

    March 19, 2014 at 9:08 am

    OK, Let me know what other specific information you might need to write the script. I would REALLY appreciate it!

    Reply
  60. Doug says

    March 4, 2014 at 8:27 am

    I think your script gets me almost to where I need to be. I'm trying to autoforward a message only when it's received from a particular email address. Can you suggest a modification that would make this work? Thanks!

    Reply
    • Diane Poremsky says

      March 4, 2014 at 8:51 am

      Setting the condition(s) in the rule is the easiest, but it doesn't always work with addresses - if outlook misses the underlying email address, you can use an if statement -
      if item.senderemailaddress = "alias@domain.com" then
      'do the stuff
      else
      end if

      Reply
  61. Russell Brown says

    March 3, 2014 at 10:08 am

    Yes, it is always a voting message.

    Reply
    • Diane Poremsky says

      March 19, 2014 at 1:38 am

      I haven't had a chance to work on this - but it looks like it is possible.

      Reply
  62. Russell Brown says

    February 28, 2014 at 12:56 pm

    So here is a tricky one for you. I want to auto reply with a script but I want it to automatically reply when a vote is sent out. The vote contains times when you would like to attend the meeting. I would like when the vote email is sent to me, to be able to auto reply that I would like to attend at 11:00. Is this possible?

    Reply
    • Diane Poremsky says

      March 3, 2014 at 1:53 am

      It probably is, but I haven't tested it. You need to be able to filter for it then pass it to the Script that finishes the processing. Is it always a voting message?

      Reply
  63. nasim rawat says

    February 15, 2014 at 6:51 am

    i want to delete top 50/60 rows or 300 words, but below this all message send

    Reply
    • Diane Poremsky says

      February 15, 2014 at 10:09 am

      You can't count words or lines (at least not without a function) but you can get characters - use right instead of left to get the end and Len to count the length. I'm on my tablet and can't see the original code, so you need to use the correct object name, but try a formula like this: body = right(body, Len(body)- 1800) (assuming AVG word length of 5+a space per word.)

      Reply
    • Diane Poremsky says

      February 15, 2014 at 11:01 am

      Here is a function that will count words - https://www.jpsoftwaretech.com/get-word-count-in-vba/ - it should work fine in outlook. You'd use it to get the word count then keep just the right most less 300. If there is a specific word or phrase in the body that is unique and never changes, at the point where you want to cut the text, you can use that in the calculation instead.

      Reply
  64. Nasim Rawat says

    February 13, 2014 at 11:42 pm

    HI Diane,
    I want to trim some rows of message body and then forward, can you help me.

    Reply
    • Diane Poremsky says

      February 14, 2014 at 12:30 am

      How much do you want to trim? use something like objMsg.body = Left(objMsg.body, 160) where 160 is the number of characters.

      Reply
  65. Jenny C says

    January 14, 2014 at 6:29 pm

    HI Diane, how do I add a short message before it gets forwarded?

    I have used this and it works
    Sub ChangeSubjectForward(Item As Outlook.MailItem)
    Item.Subject = "Test"
    Item.Save

    Set myForward = Item.Forward
    myForward.Recipients.Add "alias@domain.com"

    myForward.Send

    End Sub

    But I'd like to add a message which would be a reference for the email being sent

    Thank you

    Reply
    • Diane Poremsky says

      January 14, 2014 at 7:49 pm

      the quick and dirty way is to use item.body = "my message" & vbcrlf & item.body - if the message is HTML, you'll see why it's quick and dirty. :) it's great for plain text messages though.

      Reply
  66. Tera says

    January 7, 2014 at 7:24 am

    Unsigned macros were disabled! You are wonderful. Thank you for all your help and sharing your knowledge.

    Reply
  67. Tera says

    January 6, 2014 at 7:01 am

    Yes Ma'am. The word is in the body and the subject. I've changed it from awaiting approval to approval.
    What make this even more interesting is, if I delete the rule and set it up again it will not display either.

    Reply
    • Diane Poremsky says

      January 6, 2014 at 11:33 pm

      And the macro security is set to low or the macro is self-signed and you allow signed macros?

      Reply
  68. Tera says

    December 31, 2013 at 11:59 am

    searching the subject or body for words/phrases. I changed it from a phrase to a word.

    Reply
    • Diane Poremsky says

      January 2, 2014 at 1:57 am

      So only the words changed? Is the word in the message? <== this would be the usual reason it fails.

      Reply
  69. Tera says

    December 31, 2013 at 10:47 am

    (I mean a condition in the rule, not filter....)

    Reply
  70. Tera says

    December 31, 2013 at 10:34 am

    Thank you for sharing this script!
    I have gone through the steps and was able to complete a successful test. However, as soon as I change the filter on the rule itself the script no longer sends or displays.

    I've deleted the rule and set up a new rule, but the problem continues.

    Please advise.

    Reply
    • Diane Poremsky says

      December 31, 2013 at 11:23 am

      What condition are you trying to use?

      Reply
  71. Tex says

    December 10, 2013 at 11:17 pm

    Hi,

    I tried the code it works for me.But then, my problem is with Rules that i have set to run the script. Say, my Rule looks for the keyword 'xyz' in the subject line of received mail and triggers the script to forward the mail to a bigger group that includes myself. I again get the mail with 'xyz' in the subject line. This kind of, puts it in a loop!! Please suggest how to avoid this.

    Reply
    • Diane Poremsky says

      December 10, 2013 at 11:29 pm

      Try adding an exception to the rule "except if sent to "my dl group" or use an if statement in the script, something like this -
      If instr(1, item.to, "DL name") then
      Exit sub
      End if

      Reply
  72. Pete says

    December 9, 2013 at 3:39 pm

    Hi, I'm looking for a bit of help with a script. When I'm bcc'd on an email I want to send a new email to the original email recipient. The email needs to include an attachment and ideally the attachments vary by email domain name. I can't find the commands that I need, please could someone point me in the right direction. Thanks

    Reply
  73. Karen says

    December 8, 2013 at 2:50 am

    I put the following code in as a Application_Startup item
    So far it seems to have worked. :) Thank you for the advice on the reminders. Reminders always trigger on startup, so that's a handy redundancy feature. :)

    =====
    Private Sub Application_Startup()
    'Creates a new e-mail item and modifies its properties'

    Dim olApp As Outlook.Application
    Dim objMail As Outlook.MailItem
    Set olApp = Outlook.Application
    'Create e-mail item'
    Set objMail = olApp.CreateItem(olMailItem)

    With objMail
    .Subject = Format(Now, "YYYYMMDD - HH:mm:ss") & " | " & "Login Test"
    .Body = Format(Now, "YYYYMMDD - HH:mm:ss") & " | " & "Testing the BCC"
    .To = "me@forme"
    .Recipients.ResolveAll
    .Send
    End With
    End Sub
    =====

    Reply
  74. Karen says

    December 6, 2013 at 5:23 am

    Hi Diane, thank you for all of your posts and help so far :)
    I am using the "Send BCC" VBA code (life saver) however every now & then Outlook 2010 (on Win 8, 64) stops processing the macro after a reboot, and I don't always remember to check that the BCC is still active.

    Is there a way (I have googled but it assumes I'm referring to the auto send/receive at startup), to create an email at startup so it triggers the BCC and I can confirm it is working. .

    Eg: Outlook 2010 starts / Auto send mail to (test@testing.com)
    the Auto BCC triggers and I get an alert on my device "email received at bccadd@testing.com"

    Many thanks in advance,

    Karen

    Reply
    • Diane Poremsky says

      December 7, 2013 at 11:42 pm

      you could use an application start up to create the email, but if the bcc macro is failing, it might fail as well. It might be better to use a reminder to trigger a new email - just don't dismiss the reminder. https://www.slipstick.com/developer/send-email-outlook-reminders-fires/

      Reply
  75. Heri says

    November 26, 2013 at 3:02 am

    Diane - looking for a variation on this - wondering if you can help me. I have tried "To Forward the message body to another address" script and its working perfectly but having issue with attachment, script not able to forward attached file/files in the email, can you please advice how to forward attachment with email body ??

    Many thanks

    Reply
    • Diane Poremsky says

      November 26, 2013 at 5:12 am

      You need to the CopyAttachments sub here and then a couple of new lines in the macro before its sent.
      If Item.Attachments.Count > 0 Then
      CopyAttachments Item, objMsg
      End if
      objMsg.Send

      if you only want to include certain file types, you could take from the code here and check file types.

      Reply
  76. Craig Johnstone says

    November 4, 2013 at 8:31 am

    if you just want to forward the subject only then use the following script

    Sub SendNew(Item As Outlook.MailItem)
    Dim objMsg As MailItemSet
    objMsg = Application.CreateItem(olMailItem)
    objMsg.Body = ""
    objMsg.Subject = "FW: " & Item.Subjectobj
    Msg.Recipients.Add "alias@domain.com"
    objMsg.Send
    End Sub

    Reply
  77. Richard says

    August 28, 2013 at 1:04 am

    Hi Diane, and thanks for the reply.

    I have tried the semi colon between email AD's but that seemed to only send to the first email in the list. Having said that, now it has stopped working all together, but there are no error messages popping up. Please see a copy of script below. Sorry I am not great at scripts, although am technical.

    Sub SendNew(Item As Outlook.MailItem)
    Item.Subject = ",,[Our ref: 2M7W2NSI5NruqKI]"

    Dim objMsg As MailItem
    Set objMsg = Application.CreateItemFromTemplate("C:\old\webserver.oft")
    objMsg.Recipients.Add "01888@123.biz;01885@123.biz;01883@123.biz;01881@123.biz"

    objMsg.Send

    End Sub

    The module code is below also

    Sub webserver()

    End Sub

    Reply
    • Diane Poremsky says

      August 28, 2013 at 5:49 am

      What is your macro security set to? That is the usual cause of macros not working at all.
      Does it work if you replace the template line with a new message?
      Set objMsg = Application.CreateItem(olMailItem)

      (use objMsg.display so you can see the messages without sending them).

      Reply
  78. Richard says

    August 27, 2013 at 4:47 am

    Hi Diane
    I have used your script successfully thanks. However I would like to add multiple email recipients, and i have tried simply delimiting and repeating the objMsg.Recipients.Add line but to no avail.

    Any ideas?

    Thanks

    Richard

    Reply
    • Diane Poremsky says

      August 27, 2013 at 10:36 am

      One string with semi-colon delimiters should work -
      objMsg.Recipients.Add "alias@domain.com;another@domain.com"

      if it doesn't work for you, what does the error message say?

      Reply
  79. Alap says

    August 14, 2013 at 7:57 am

    Hi there,

    We are in a situation where we have a mailbox, which receives e-mails from abc@netbanx.com. The body of the e-mail contains our customer's e-mail address specified as E-mail Address: joe.bloggs@xyz.com

    We would like these e-mails to be forwarded to the customers by picking up the E-mail Address field in the body.

    Is there a script for this?

    Reply
    • Diane Poremsky says

      August 14, 2013 at 3:16 pm

      You'll need to parse the body and look for the address, and yes, i have a script for that. :)

      Use regex to get values has the basics, https://forums.slipstick.com/ has a sample. There is a run a script rule sample as the last macro on this page - run-script-rule-change-subject-message/

      Reply
  80. seb says

    July 11, 2013 at 11:40 pm

    hi there, i like this but was looking for a script that allowed me to automatically forward an email to someone@company.com with a message in the body. ie please see my email below.

    Reply
    • Diane Poremsky says

      July 12, 2013 at 4:23 am

      To add a note to the body, you'd use something like this:
      objMsg.Body = "Please see message below" & vbcrlf & vbcrlf & Item.Body

      Reply
  81. Rupesh says

    May 3, 2013 at 11:29 pm

    what i have to insert in this option objMsg.Body

    Reply
    • Diane Poremsky says

      May 4, 2013 at 5:10 pm

      I'm not sure I understand the question. Sorry.

      Reply
  82. Misa says

    April 19, 2013 at 3:40 am

    Yes Diane, I would need this for my WEB site. When I contacted support they told me that I need script for this, and now I'm looking for someone who can help me with it...

    Reply
    • Diane Poremsky says

      April 19, 2013 at 8:16 am

      It's really out of my league. Sorry. If you site uses php or asp, you can use that otherwise, you need javascript.
      google search. If you can't find anything (the results on page 2 looked promising, page 1 was mostly commercial services). Back before I moved to use a CMS, stackexchange and dynamicdrive seemed to have the most useful scripts but that was 3+ years ago.

      If all else fails you could do it in outlook, but the reply won't be fast since outlook needs to download the mail to reply. If you web mail can autoreply, you could set it up in the mailbox and replies will be fast.

      Reply
  83. Barney says

    April 19, 2013 at 2:14 am

    the macro setting in my outlook is set to 'Notifications for digitally signed macros, all other macros disabled' and this is greyed out, therefore I cannot change the setting. Must be set by GP. Are you familiar with how I can disable this via local security policy?

    Reply
    • Diane Poremsky says

      April 19, 2013 at 8:22 am

      If you have the ability to edit the registry (I'm guessing they have that locked down too), you can override it after each logon by deleting the key. But it's really best to talk to your admin.

      Reply
  84. Barney says

    April 18, 2013 at 7:54 pm

    Diane
    The outlook template file does not display, nor do I get the message box pop up. Wondering if these things may be blocked by group policy, do you know?

    Reply
    • Diane Poremsky says

      April 18, 2013 at 7:59 pm

      Do you have macro security set to low? As long as you can change the macro security to either low are warn for all macros, they can't block it.

      Reply
  85. Misa says

    April 18, 2013 at 6:25 pm

    Hello,Can anyone help me with this issue : How to make "personalized auto-responder", if I can call it this way....
    Any decent WEB site today have (if we can call it) customized auto reply message when customer sign up with them.
    Example : If I register with some WEB site I receive message similar to this:
    Dear Misa,Thank you for registering with our website.
    Your details are as follows:-
    Username: Misa
    Password: Provided when you registered.
    So in just few seconds I'm receiving automated message with my name and user name,also if I loose password I can recover it.
    Can anyone tell me how I can get something like this, do I need additional software (or service)?Many thanks

    Reply
    • Diane Poremsky says

      April 18, 2013 at 11:11 pm

      Do you want this on your web site? If so, you would use a script in the web page, not in outlook. If you use exchange server, you could have it generate a reply (pop and imap servers might be able to do it too) but having the form generate and send it would be easier.

      Reply
  86. Mark says

    April 18, 2013 at 2:44 pm

    No, I currently just have a standard rule created through the Outlook rules wizard. Just trying to find a way to forward only meetings that are not all day events. The rules wizard doesn't account for this, and it looks as though I need to use a script or macro.

    Reply
    • Diane Poremsky says

      April 18, 2013 at 3:44 pm

      You'll need to use a run a script rule. I'd probably build off of the rule here: autoaccept meeting - you can add the bit that checks for the all day state to the if statement, then add code to forward and remove the autoaccept bits.

      Reply
  87. Mark says

    April 17, 2013 at 3:38 pm

    Diane - looking for a variation on this - wondering if you can help me. At our work site, I can't sync my google calendar with my work calendar because it's blocked. So I have a rule to forward meeting requests to my google calendar. The problem is that we also use "all day events" as a way to show someone is out of the office. I don't want these appointments forwarded to my google calendar, and I can't find a way to exclude them from the rule.

    Any advice?

    Thanks

    Reply
    • Diane Poremsky says

      April 17, 2013 at 9:06 pm

      You'd add an if statement -

      If Appt.AllDayEvent = False then
      'do the forward
      else
      end if

      Do you have code you are using now or are you trying to convert this macro to something that meets your need?

      Reply
  88. Barney says

    April 16, 2013 at 5:26 am

    Hi Diane
    I have checked and the syntax was correct, also changed the 'send' to 'display' when I run the rule the template does not open.
    =====================
    Sub SendNew(Item As Outlook.MailItem)

    Dim objMsg As MailItem
    Set objMsg = Application.CreateItemFromTemplate("C:\OFT\Rule1.oft")

    ' If the address you want to send to is not saved in the template,
    ' set the addresses here
    objMsg.Recipients.Add "bk@acp.com.au"

    objMsg.Display

    End Sub

    Reply
    • Diane Poremsky says

      April 16, 2013 at 7:09 am

      This is working here - I added MsgBox "SendNow rule" so I'd know if it kicked in.
      Sub SendNew(Item As Outlook.mailItem)
      MsgBox "SendNow rule"
      Dim objMsg As mailItem
      Set objMsg = Application.CreateItemFromTemplate("C:\OFT\Rule1.oft")
      ' If the address you want to send to is not saved in the template,
      ' set the addresses here
      objMsg.Recipients.Add "alias@domain.com"
      objMsg.Display
      End Sub

      It worked with that removed too - once i fixed my rule. I initially used conditions than my test messages did not meet. :(

      Reply
  89. Barney says

    April 14, 2013 at 9:47 pm

    Hi There
    I have an Outlook 2010 rule that runs whenever any emails from a specific user, with specific subject line and body text is detected. I know this rule works as I set up this rule with a simple forward rule and it work.
    However I want to execute your script 'New message using a template' as I want to trigger a whole new email and send it to specific users.
    I copied your code, followed your instructions but nothing happens.
    the outlook template file resides in c:\OFT\Rule1.oft
    This is what my script looks like
    ============================================
    Sub SendNew(Item As Outlook.MailItem)

    Dim objMsg As MailItem
    Set objMsg = Application.CreateItemFromTemplate("C:\OFT\Rule1.oft")

    ' If the address you want to send to is not saved in the template,
    ' set the addresses here
    bjMsg.Recipients.Add "bk@acp.com.au"

    objMsg.Send

    End Sub
    ============================================
    How can I toubleshoot this further? Any help would be greatly appreciated.

    Reply
    • Diane Poremsky says

      April 15, 2013 at 5:04 pm

      Change .send to .display so you can see if the template opens.

      Oh, and if this is not a typo, you are missing the o.
      bjMsg.Recipients.Add "bk@acp.com.au

      Reply
  90. Eric says

    February 27, 2013 at 8:50 am

    Got it to work. :)

    Reply
  91. Eric says

    February 27, 2013 at 7:42 am

    Yes, but I've added a forwarding message and an email address. Sorry, first time trying to use the script option.

    objMsg.Subject = "FW: Forwarded to supportcase " & Item.Subject
    objMsg.Recipients.Add "Eric@companyname.com"

    Reply
  92. Manuel Ratzinger says

    February 27, 2013 at 1:38 am

    Thx, I figured that out already. Works fine for me.

    Reply
  93. Eric says

    February 26, 2013 at 6:32 pm

    I'm trying to use the To Forward the message body to another address script and I get a compile error on the first line. User-defined type not defined. I have excel 2010. Please help. Thanks

    Reply
    • Diane Poremsky says

      February 26, 2013 at 6:55 pm

      Are you using the code exactly as shown in the sample?

      Reply
  94. Manuel Ratzinger says

    February 19, 2013 at 6:00 am

    Hello,

    thx for that usefull post. I have a little different problem to solve. Do you know how it is possible to do the same thing as above but use a "alias" mail address to send the reply mail as a user could choose manualy in the "From..." Menue in a new Outlook E-Mail User Interface.

    I know the possibility with the SendUsingAccount method, but the problem is there is no additional account but the user has only the right to send as another user.

    Reply
    • Diane Poremsky says

      February 24, 2013 at 6:32 am

      Try using SentOnBehalfOfName -

      objMsg.SentOnBehalfOfName = "me@here.com"

      Reply

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

Visit Slipstick Forums.
What's New at Slipstick.com

Latest EMO: Vol. 31 Issue 5

Subscribe to Exchange Messaging Outlook






Support Services

Do you need help setting up Outlook, moving your email to a new computer, migrating or configuring Office 365, or just need some one-on-one assistance?

Our Sponsors

CompanionLink
ReliefJet
  • Popular
  • Latest
  • Week Month All
  • Jetpack plugin with Stats module needs to be enabled.
  • Sync Issues and Errors with Gmail and Yahoo accounts
  • Error Opening iCloud Appointments in Classic Outlook
  • Opt out of Microsoft 365 Companion Apps
  • Mail Templates in Outlook for Windows (and Web)
  • Urban legend: Microsoft Deletes Old Outlook.com Messages
  • Buttons in the New Message Notifications
  • Move Deleted Items to Another Folder Automatically
  • Open Outlook Templates using PowerShell
  • Count and List Folders in Classic Outlook
  • Google Workspace and Outlook with POP Mail
Ajax spinner

Recent Bugs List

Microsoft keeps a running list of issues affecting recently released updates at Fixes or workarounds for recent issues in classic Outlook (Windows).

For new Outlook for Windows: Fixes or workarounds for recent issues in new Outlook for Windows .

Outlook for Mac Recent issues: Fixes or workarounds for recent issues in Outlook for Mac

Outlook.com Recent issues: Fixes or workarounds for recent issues on Outlook.com

Office Update History

Update history for supported Office versions is at Update history for Office

Outlook Suggestions and Feedback

Outlook Feedback covers Outlook as an email client, including Outlook Android, iOS, Mac, and Windows clients, as well as the browser extension (PWA) and Outlook on the web.

Outlook (new) Feedback. Use this for feedback and suggestions for Outlook (new).

Use Outlook.com Feedback for suggestions or feedback about Outlook.com accounts.

Other Microsoft 365 applications and services




New Outlook Articles

Sync Issues and Errors with Gmail and Yahoo accounts

Error Opening iCloud Appointments in Classic Outlook

Opt out of Microsoft 365 Companion Apps

Mail Templates in Outlook for Windows (and Web)

Urban legend: Microsoft Deletes Old Outlook.com Messages

Buttons in the New Message Notifications

Move Deleted Items to Another Folder Automatically

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Google Workspace and Outlook with POP Mail

Newest Code Samples

Open Outlook Templates using PowerShell

Count and List Folders in Classic Outlook

Insert Word Document into Email using VBA

Warn Before Deleting a Contact

Use PowerShell to Delete Attachments

Remove RE:, FWD:, and Other Prefixes from Subject Line

Change the Mailing Address Using PowerShell

Categorize @Mentioned Messages

Send an Email When You Open Outlook

Delete Old Calendar Events using VBA

VBA Basics

How to use the VBA Editor

Work with open item or selected item

Working with All Items in a Folder or Selected Items

VBA and non-default Outlook Folders

Backup and save your Outlook VBA macros

Get text using Left, Right, Mid, Len, InStr

Using Arrays in Outlook macros

Use RegEx to extract message text

Paste clipboard contents

Windows Folder Picker

Custom Forms

Designing Microsoft Outlook Forms

Set a custom form as default

Developer Resources

Developer Resources

Developer Tools

VBOffice.net samples

SlovakTech.com

Outlook MVP David Lee

Repair PST

Convert an OST to PST

Repair damaged PST file

Repair large PST File

Remove password from PST

Merge Two Data Files

Sync & Share Outlook Data

  • Share Calendar & Contacts
  • Synchronize two computers
  • Sync Calendar and Contacts Using Outlook.com
  • Sync Outlook & Android Devices
  • Sync Google Calendar with Outlook
  • Access Folders in Other Users Mailboxes

Diane Poremsky [Outlook MVP]

Make a donation

Mail Tools

Sending and Retrieval Tools

Mass Mail Tools

Compose Tools

Duplicate Remover Tools

Mail Tools for Outlook

Online Services

Calendar Tools

Schedule Management

Calendar Printing Tools

Calendar Reminder Tools

Calendar Dates & Data

Time and Billing Tools

Meeting Productivity Tools

Duplicate Remover Tools

Productivity

Productivity Tools

Automatic Message Processing Tools

Special Function Automatic Processing Tools

Housekeeping and Message Management

Task Tools

Project and Business Management Tools

Choosing the Folder to Save a Sent Message In

Run Rules on messages after reading

Help & Suggestions

Submit Outlook Feature Requests

Slipstick Support Services

Buy Microsoft 365 Office Software and Services

Visit Slipstick Forums.

What's New at Slipstick.com

Home | Outlook User | Exchange Administrator | Office 365 | Outlook.com | Outlook Developer
Outlook for Mac | Common Problems | Utilities & Addins | Tutorials
Outlook & iCloud Issues | Outlook Apps
EMO Archives | About Slipstick | Slipstick Forums
Submit New or Updated Outlook and Exchange Server Utilities

Send comments using our Feedback page
Copyright © 2026 Slipstick Systems. All rights reserved.
Slipstick Systems is not affiliated with Microsoft Corporation.