Results 1 to 9 of 9

Thread: MS Outlook custom rule help

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    6

    MS Outlook custom rule help

    Hello all,

    I am trying to figure out a way to create a custom rule in Outlook to display an alert/notification or sound based on a future time after a specific e-mail arrives. Listed below is what I'm trying for:

    1. An email arrives with a subject keyword "severity - 3"
    2. This triggers the rule to send a notification/alert or sound 5 hours from when that e-mail arrived.

    I have searched all over without having much luck in this. Can someone please help?

    Thank you,
    Mike

  2. #2
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: MS Outlook custom rule help

    Welcome to the forums.

    What version of Office are you using?

  3. #3

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    6

    Re: MS Outlook custom rule help

    Thanks

    I'm using Office 2007

  4. #4
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: MS Outlook custom rule help

    Have you gone through The Rules and Alerts Wizard in Outlook?

  5. #5

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    6

    Re: MS Outlook custom rule help

    Yes, I have gone through it quite extensively. The only way I figure this could be done easily would be to create a custom VBA macro to have Outlook take the email, create a task using the subject line from the email and set a reminder trigger for 5 hours from the time that task was created. However, I do not know anything about VBA at all.

  6. #6
    I'm about to be a PowerPoster! Hack's Avatar
    Join Date
    Aug 2001
    Location
    Searching for mendhak
    Posts
    58,333

    Re: MS Outlook custom rule help

    In that case, you might want to check out some of the third party add-ins that have been created for Outlook.

    Here are some links that might be useful for you.

    Outlook Custom Add-ins

  7. #7

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    6

    Re: MS Outlook custom rule help

    Thanks for the suggestions, Hack. I found a couple websites that had some examples I could relate to, and was able to piece together the code I needed, which works great.

    Code:
    Sub ProcessMailItemIntoTask(Item As Outlook.MailItem)
        Dim strTaskName As String
        strTaskName = Trim(Item.Subject)
        
        If Len(strTaskName) < 1 Then
            ' No subject - use the first line of the body
            strTaskName = Trim(Item.Body)
            Dim intCrLfPos As Integer
            intCrLfPos = InStr(1, strTaskName, Constants.vbCrLf, vbTextCompare)
            If intCrLfPos > 0 Then
                strTaskName = Trim(Left(strTaskName, intCrLfPos - 1))
            End If
        End If
    
        ' Create the task
        Dim objTask As Outlook.TaskItem
        Set objTask = Application.CreateItem(olTaskItem)
        objTask.Subject = strTaskName
        objTask.StartDate = Item.ReceivedTime
        objTask.ReminderSet = True
        objTask.ReminderTime = DateAdd("h", 5, Now)
        objTask.Save
        Set objTask = Nothing
    
    
    End Sub
    This script takes any e-mail and automatically creates a task using the same subject line, or first line in the body if there are no subject, and creates a reminder for 5-hours from the time that email arrived.

  8. #8

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    6

    Re: MS Outlook custom rule help

    Actually, if anyone knows how I could incorporate that script to only count the hours between 8am-5pm, that would be great. Not sure if that is even possible though.

  9. #9

    Thread Starter
    New Member
    Join Date
    Nov 2011
    Posts
    6

    Re: MS Outlook custom rule help

    Ok, this is very odd. This code worked great for one day. After I rebooted my computer and opened up Outlook again, it does not work anymore. I verified the rule is still active and nothing has changed in the script. There aren't any error messages either. It just stopped working. Any ideas?

    vb Code:
    1. Sub ProcessMailItemIntoTask(Item As Outlook.MailItem)
    2.     Dim strTaskName As String
    3.     strTaskName = Trim(Item.Subject)
    4.    
    5.     If Len(strTaskName) < 1 Then
    6.         ' No subject - use the first line of the body
    7.         strTaskName = Trim(Item.Body)
    8.         Dim intCrLfPos As Integer
    9.         intCrLfPos = InStr(1, strTaskName, Constants.vbCrLf, vbTextCompare)
    10.         If intCrLfPos > 0 Then
    11.             strTaskName = Trim(Left(strTaskName, intCrLfPos - 1))
    12.         End If
    13.     End If
    14.  
    15.     ' Create the task
    16.     Dim objTask As Outlook.TaskItem
    17.     Set objTask = Application.CreateItem(olTaskItem)
    18.     objTask.Subject = strTaskName
    19.     objTask.StartDate = Item.ReceivedTime
    20.     objTask.ReminderSet = True
    21.     objTask.ReminderTime = DateAdd("h", 5, Now)
    22.     objTask.Save
    23.     Set objTask = Nothing
    24.  
    25.  
    26. End Sub

Posting Permissions

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



Click Here to Expand Forum to Full Width