Consulting

Results 1 to 4 of 4

Thread: VBA rule setting

  1. #1

    VBA rule setting

    Hello,

    I need help in setting a rule in Outlook through VBA.

    I want to create a rule so that when an email arrives

    1) from a specific person , say from Adam
    2) specific subject , say hello
    3) arrives with in workdays of the week (Monday to Friday)

    then

    Start an application (.exe file on c drive)

    I can do all this by using "rules" option, except the timing condition (3rd , Monday-Friday)
    so i need a vba code that can do the entire thing

    Thank you so much for the help !

  2. #2
    This is simple enough to achieve with a script associated with a rule to identify the incoming messages e.g.

    Sub ProcessMessage(Item As Outlook.MailItem)
    Dim iDay As Integer
        iDay = Weekday(Item.ReceivedTime, vbMonday)
        Select Case iDay
            Case 1, 2, 3, 4, 5
                MsgBox "It's a weekday"
                'do weekday stuff
            Case Else
                MsgBox "It's weekend"
                'do weekend stuff
        End Select
    lbl_Exit:
        Exit Sub
    End Sub
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

  3. #3
    Hi Garahm,

    Thanks a lot for the help. How do I associate this script with the rule ?

    Much appreciate your help

    Fahad

  4. #4
    When you create the rule to process incoming messages running a script is one of the options available. Select the above script, which should have been copied to a module in Outlook VBA - see also http://www.gmayor.com/create_and_emp...gital_cert.htm
    Graham Mayor - MS MVP (Word) 2002-2019
    Visit my web site for more programming tips and ready made processes
    http://www.gmayor.com

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •