Hide Outlook Envelope in System Tray

G

Greg Lister

I have written an add-in which scans the mailbox when mail arrives and logs certain messages. Once the message has been processed, it is marked as 'read'. This process works well, except that the envelope icon in the system tray stays visible even if there are no unread messages in the in-box.

Is there a way to programmatically refresh the envelope icon?
 
W

Wei-Dong Xu [MSFT]

Hi,

Thanks for posting in the community!

From my understanding to this issue, when there is no any unread mail
messages in the inbox, you are going to hide the outlook notification
system tray icon.

So far as I know, the hiding of the envelop icon is not synchronized with
the unread messages. This means if all the messages have been set to "read"
state, the envelope icon will still stay in the system tray. Then for one
minutes or longer, it will disappear. It is a feature by design. I am now
researching more for you on this issue. I will post back no matter whether
I have found one solution.

Have a good weekend!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.
 
G

Greg Lister

Wei-Dong
Thanks for getting involved in this
Some further information: When I programmatically set all items to 'read', the icon stays in the system tray. The only way I can get it to go away is to open and close a mail message with the UI (i.e. one which has already been read). When the message is closed, the tray is refreshed and the icon disappears. So somehow the UI knows how to refresh the system tray
Rgds
Greg.
 
W

Wei-Dong Xu [MSFT]

Hi Greg,

Based on my research, there is no way for us now to control this new mail
notification envelop icon from Outlook Object. This is because in some
scenario, outlook will not show this icon due to some low level
restriction, for example in NAT.
304849 OL2000: You Cannot Receive New E-mail Notifications in Environments
That
http://support.microsoft.com/?id=304849

So there is no interface available of Outlook object for us to control the
icon. Since this control relates to the Outlook design, I'd recommend that
you forward this to the Microsoft Wish Program using one of the methods
listed below. This feature may be included in the future version.
1. World Wide Web
a)In Internet Explorer 6, click Send Feedback on the Help menu and then
click the link in the Product Suggestion section of the page that appears.
b)In Windows XP, click Help and Support on the Start menu. Click Send
your feedback to Microsoft, and then fill out the Product Suggestion page
that appears.
c)Visit the following Microsoft Web site:
http://www.microsoft.com/ms.htm
d)Click Microsoft.com Guide in the upper-right corner of the page and
then click Contact Us . Click the link in the Product Suggestion section of
the page that appears.
e)Visit the following Microsoft Product Feedback Web site
http://register.microsoft.com/mswish/suggestion.asp
and then complete and submit the form.

2. E-mail - To send comments or suggestions via e-mail, use the following
Microsoft Wish Program e-mail address, (e-mail address removed).

3. FAX - To send comments or suggestions via FAX, use the following
Microsoft FAX number, (425) 936-7329.
NOTE : Address the FAX to the attention of the Microsoft Wish Program.

4. US Mail - To send comments or suggestions via US Mail, use the following
Microsoft mailing address:
Microsoft Corporation
Attn. Microsoft Wish Program
One Microsoft Way
Redmond, WA 98052-6399

Have a nice day!

Wei-Dong Xu
Microsoft Product Support Services
Get Secure! - www.microsoft.com/security
This posting is provided "AS IS" with no warranties, and confers no rights.

MORE INFORMATION
Each product suggestion is read by a member of our product feedback team,
classified for easy access, and routed to the product or service team to
drive Microsoft product and/or service improvements. Because we receive an
abundance of suggestions (over 69,000 suggestions a year!) we can't
guarantee that each request makes it into a final product or service. But
we can tell you that each suggestion has been received and is being
reviewed by the team that is most capable of addressing it.
 
A

Andrew Cushen

Greg:

I am going to re-post some code George Hester
<[email protected]> posted on this newsgroup
recently, along with the suggestion to please read back a
few pages of messages, or Search the messages, before
posting a question that may already have been answered.

-Andrew
=====================
I Quote:

<<
It's not mine:

Option Explicit
Public Const WUM_RESETNOTIFICATION As Long = &H407
Public Const NIM_ADD As Long = &H0
Public Const NIM_MODIFY As Long = &H1
Public Const NIM_DELETE As Long = &H2
Public Const NIF_ICON As Long =
&H2 'adding an icon
Public Const NIF_TIP As Long =
&H4 'adding a tip
Public Const NIF_MESSAGE As Long = &H1 'want
return messages

'Structure needed for Shell_Notify API
Public Type NOTIFYICONDATA
cbSize As Long
hwnd As Long
uID As Long
uFlags As Long
uCallbackMessage As Long
hIcon As Long
szTip As String * 64
End Type

Public 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

Public Declare Function GetClassName Lib "user32" _
Alias "GetClassNameA" _
(ByVal hwnd As Long, _
ByVal lpClassName As String, _
ByVal nMaxCount As Long) As Long

Public Declare Function GetWindowTextLength Lib "user32" _
Alias "GetWindowTextLengthA" _
(ByVal hwnd As Long) As Long

Public Declare Function GetWindowText Lib "user32" _
Alias "GetWindowTextA" _
(ByVal hwnd As Long, _
ByVal lpString As String, _
ByVal cch As Long) As Long

Public Declare Function EnumWindows Lib "user32" _
(ByVal lpEnumFunc As Long, _
ByVal lParam As Long) As Long

Public Declare Function Shell_NotifyIcon Lib "shell32.dll"
_
Alias "Shell_NotifyIconA" _
(ByVal dwMessage As Long, _
lpData As NOTIFYICONDATA) As Long

Public Declare Function FindWindow Lib "user32" _
Alias "FindWindowA" _
(ByVal lpClassName As String, _
ByVal lpWindowName As String) As Long

Public Function EnumWindowProc(ByVal hwnd As Long, _
ByVal lParam As Long) As
Long
'do stuff here with hwnd
Dim sClass As String
Dim sIDType As String
Dim sTitle As String
Dim hResult As Long
sTitle = GetWindowIdentification(hwnd, sIDType, sClass)
If sTitle = "rctrl_renwnd32" Then
hResult = KillNewMailIcon(hwnd)
End If
If hResult Then
EnumWindowProc = False
'Reset the new mail notification engine
Call SendMessage(hwnd, WUM_RESETNOTIFICATION, 0&,
0&)
Else
EnumWindowProc = True
End If
End Function
Public Function GetWindowIdentification(ByVal hwnd As
Long, _
sIDType As String,
_
sClass As String)
As String
Dim nSize As Long
Dim sTitle As String
'Get the size of the string required
'to hold the window title
nSize = GetWindowTextLength(hwnd)
'If the return is 0, there is no title
If nSize > 0 Then
sTitle = Space$(nSize + 1)
Call GetWindowText(hwnd, sTitle, nSize + 1)
sIDType = "title"
sClass = Space$(64)
Call GetClassName(hwnd, sClass, 64)
Else
'No title, so get the class name instead
sTitle = Space$(64)
Call GetClassName(hwnd, sTitle, 64)
sClass = sTitle
sIDType = "class"
End If
GetWindowIdentification = TrimNullMain(sTitle)
End Function
Public Function KillNewMailIcon(ByVal hwnd As Long) As
Boolean
Dim pShell_Notify As NOTIFYICONDATA
Dim hResult As Long
'Set up the Shell_Notify structure
pShell_Notify.cbSize = Len(pShell_Notify)
pShell_Notify.hwnd = hwnd
pShell_Notify.uID = 0
'Remove it from the system tray and catch result
hResult = Shell_NotifyIcon(NIM_DELETE, pShell_Notify)
If (hResult) Then
KillNewMailIcon = True
Else
KillNewMailIcon = False
End If
End Function
Public Function TrimNullMain(strItem As String) As String
Dim pos As Integer
pos = InStr(strItem, Chr$(0))
If pos Then
TrimNullMain = Left$(strItem, pos - 1)
Else: TrimNullMain = strItem
End If
End Function

Public Sub RemoveNewMailIcon()
EnumWindows AddressOf EnumWindowProc, 0
End Sub

Put this in a module. I put a shortcut to it in my menu.

http://support.microsoft.com/?scid=kb;en-us;292797
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top