none
[Outlook] Add rule : Run a script RRS feed

  • Question

  • Hi,

    I really have no knowledge in Script or VBA language, but I need to set a rule that will run a script to find a text within the email, change the subject and save.

    Here is a detailed explanation:

    1. Email received:

              From: example@domain.com 

              Subject: New email

              This item# is for you. bla bla bla.

    2. Run rule:

              a. from : example@domain.com & Subject: New email

              b. Run script :

    i.   find : item#

            ii.  Set email subject to: item#

               iii. Save email.

    3. Result:

    From: Example@domain.com 

              Subject: item#

              This item# is for you. bla bla bla.

    fyi,

    Item# is numeric (digits) and it change every email.

    I know how to set a new rule, I just need the script to find, edit & save.

    fyi (2),

    I'm not a tech lol

    Thanks !


    • Edited by M-1-N Wednesday, September 7, 2016 3:43 PM typo
    Wednesday, September 7, 2016 1:28 PM

Answers

  • Hello,

    The forum is for developers. I'd suggest hiring a developer (for example, a freelancer) who can develop a solution for your needs. Tech forums is not a place for requesting a ready-made code/solution.

    I'd be happy to help if you face with any technical problem. Basically the VBA macro should look like the following one:

    Public Sub Test(mail as MailItem)
      ' your code goes there
    End Sub

    where the mail object represents the email against which the macro is run. As you may see there is no need to search for the item.

    The Subject property of the MailItem class can be used to set the subject line.

    Public Sub Test(mail as MailItem)
      mail.Subject = "item#"
    End Sub

    And the Save method can be used for saving it. The method saves the Microsoft Outlook item to the current folder or, if this is a new item, to the Outlook default folder for the item type.

    Public Sub Test(mail as MailItem)
      mail.Subject = "item#"
      mail.Save()
    End Sub

    The Outlook object model provides three main ways for dealing with the message bodies. You can read more about them in the Chapter 17: Working with Item Bodies article.

    Finally, you may find the Getting Started with VBA in Outlook 2010 article helpful.


    [custom.development]

    • Proposed as answer by David_JunFeng Sunday, September 18, 2016 1:54 PM
    • Marked as answer by David_JunFeng Monday, September 19, 2016 5:35 AM
    Wednesday, September 7, 2016 3:06 PM

All replies

  • Hello,

    The forum is for developers. I'd suggest hiring a developer (for example, a freelancer) who can develop a solution for your needs. Tech forums is not a place for requesting a ready-made code/solution.

    I'd be happy to help if you face with any technical problem. Basically the VBA macro should look like the following one:

    Public Sub Test(mail as MailItem)
      ' your code goes there
    End Sub

    where the mail object represents the email against which the macro is run. As you may see there is no need to search for the item.

    The Subject property of the MailItem class can be used to set the subject line.

    Public Sub Test(mail as MailItem)
      mail.Subject = "item#"
    End Sub

    And the Save method can be used for saving it. The method saves the Microsoft Outlook item to the current folder or, if this is a new item, to the Outlook default folder for the item type.

    Public Sub Test(mail as MailItem)
      mail.Subject = "item#"
      mail.Save()
    End Sub

    The Outlook object model provides three main ways for dealing with the message bodies. You can read more about them in the Chapter 17: Working with Item Bodies article.

    Finally, you may find the Getting Started with VBA in Outlook 2010 article helpful.


    [custom.development]

    • Proposed as answer by David_JunFeng Sunday, September 18, 2016 1:54 PM
    • Marked as answer by David_JunFeng Monday, September 19, 2016 5:35 AM
    Wednesday, September 7, 2016 3:06 PM
  • Hi M-1-N,

    According to your description, you could create a script for the Rules Wizard in Outlook. The Outlook Rules Wizard allows you to "run a script" when you create a specific rule. As a developer, this allows you to perform an action on incoming mail that is not possible using the regular features of the Rules Wizard.

    For more information, click here to refer about How to create a script for the Rules Wizard in Outlook

    Thursday, September 8, 2016 2:36 AM