| {\rtf1\ansi\ansicpg1252\deff0\deflang1044{\fonttbl{\f0\fnil\fcharset0 MS Sans Serif;}} \viewkind4\uc1\pard\f0\fs17 The following code removes the new mail icon (an envelope) that outlook places in the system tray when you receive a new mail message. \par \par This code would typically be called when the Application.NewMail event fires. eg, \par \par Private Sub Application_NewMail() \par OutlookRemoveMailIcon \par End Sub \par \par Source Code: \par \par Option Explicit \par \par Private Type NOTIFYICONDATA \par cbSize As Long \par hwnd As Long \par uID As Long \par uFlags As Long \par uCallbackMessage As Long \par hIcon As Long \par szTip As String * 64 \par End Type \par \par Private Declare Function SendMessage Lib "user32" Alias "SendMessageA" (ByVal hwnd As Long, ByVal wMsg As Long, ByVal wParam As Integer, ByVal lParam As Any) As Long \par Private Declare Function GetClassName Lib "user32" Alias "GetClassNameA" (ByVal hwnd As Long, ByVal lpClassName As String, ByVal nMaxCount As Long) As Long \par Private Declare Function Shell_NotifyIcon Lib "shell32.dll" Alias "Shell_NotifyIconA" (ByVal dwMessage As Long, lpData As NOTIFYICONDATA) As Long \par Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Long \par Private Declare Function FindWindowEx Lib "user32" Alias "FindWindowExA" (ByVal hWnd1 As Long, ByVal hWnd2 As Long, ByVal lpsz1 As String, ByVal lpsz2 As String) As Long \par Private Declare Function GetWindow Lib "user32" (ByVal hwnd As Long, ByVal wCmd As Long) As Long \par \par \par 'Purpose : Removes the name mail icon from outlook \par 'Inputs : [bDontShowAgain] If True the new mail icon won't show again when you receive a new mail message. \par 'Outputs : Returns True if a Outlook mail icon was deleted \par \par \par Public Function OutlookRemoveMailIcon(Optional bDontShowAgain As Boolean = False) As Boolean \par Const WUM_RESETNOTIFICATION As Long = &H407 \par Const GW_HWNDNEXT As Long = 2, GW_HWNDFIRST = 0 \par Const NIM_DELETE As Long = &H2 \par \par Dim sBuffer As String * 64 \par Dim lhShellTray As Long \par Dim lhTrayWindow As Long \par Dim lhIcon As Long \par Dim tNotify As NOTIFYICONDATA \par \par 'Get the Taskbar handle \par lhShellTray = FindWindow("Shell_TrayWnd", vbNullString) \par 'Find the first window on the task bar \par lhIcon = GetWindow(lhShellTray, GW_HWNDFIRST) \par \par Do While lhIcon \par 'Loop through each window in the task bar, checking the class name \par Call GetClassName(lhIcon, sBuffer, 64) \par If Left$(sBuffer, 14) = "rctrl_renwnd32" Then \par 'Found correct class name, try to remove icon \par 'Setup a notify icon structure \par tNotify.cbSize = Len(tNotify) \par tNotify.hwnd = lhIcon \par tNotify.uID = 0 \par 'Try to delete the system tray icon \par If Shell_NotifyIcon(NIM_DELETE, tNotify) Then \par 'Deleted icon \par If bDontShowAgain = False Then \par 'Reset the mail engine (else new mail icons won't appear again) \par Call SendMessage(lhIcon, WUM_RESETNOTIFICATION, 0&, 0&) \par End If \par OutlookRemoveMailIcon = True \par Exit Do \par End If \par End If \par 'Get the next taskbar window \par lhIcon = GetWindow(lhIcon, GW_HWNDNEXT) \par Loop \par End Function \par } |
Deleting the "New Mail Icon" from outlook |
India web developer web development India | India web development company India ecommerce web developer