Display new mail icon in Windows taskbar using VBScript

前端 未结 4 656
南方客
南方客 2021-01-05 14:10

I was having the hardest time configuring outlook to show the new mail message icon only when I wanted it to. I have several rules/filters set up that I didn\'t want to sho

4条回答
  •  余生分开走
    2021-01-05 14:56

    I had got the same problem, but since Windows 7 I don't look for a tray icon, instead I look on the outlook task button.

    I wrote the following script to notify windows that the outlook task bar button shall start to flash until the outlook window becomes active. The script must be executed from the rule.

    Option Explicit
    
    Private Type FLASHWINFO
      cbSize As Long
      hWnd As Long
      dwFlags As Long
      uCount As Long
      dwTimeout As Long
    End Type
    
    Private Declare Sub ZeroMemory Lib "kernel32.dll" Alias "RtlZeroMemory" (ByRef pData As Any, ByVal nSize As Long)
    Private Declare Function FlashWindowEx Lib "user32.dll" (ByRef pFlashWInfo As FLASHWINFO) As Boolean
    Private Declare Function FindWindowEx Lib "user32.dll" Alias "FindWindowExA" (ByVal hWndParent As Long, ByVal hWndChildAfter As Long, ByVal lpszClass As String, ByVal lpszWindow As String) As Long
    
    Private Const FLASHW_ALL As Long = &H3&
    Private Const FLASHW_CAPTION As Long = &H1&
    Private Const FLASHW_STOP As Long = &H0&
    Private Const FLASHW_TIMER As Long = &H4&
    Private Const FLASHW_TIMERNOFG As Long = &HC&
    Private Const FLASHW_TRAY As Long = &H2&
    
    Public Sub OnNotification(Item As Outlook.MailItem)
      Dim fwi As FLASHWINFO
    
      Call ZeroMemory(fwi, Len(fwi))
      fwi.cbSize = Len(fwi)
      fwi.hWnd = GetHWND
      fwi.dwFlags = FLASHW_TRAY Or FLASHW_TIMERNOFG
      fwi.uCount = -1
      fwi.dwTimeout = 0
      Call FlashWindowEx(fwi)
    End Sub
    
    Private Function GetHWND() As Long
      GetHWND = FindWindowEx(0, 0, vbNullString, Application.ActiveWindow.Caption)
    End Function
    

    This is a suitable solution for my problem.

提交回复
热议问题