SHGetUnreadMailCountA function (shellapi.h)

Retrieves a specified user's unread message count for any or all email accounts.

Syntax

HRESULT SHGetUnreadMailCountA(
  [in, optional]  HKEY     hKeyUser,
  [in, optional]  LPCSTR   pszMailAddress,
  [out, optional] DWORD    *pdwCount,
  [out, optional] FILETIME *pFileTime,
  [out, optional] LPSTR    pszShellExecuteCommand,
                  int      cchShellExecuteCommand
);

Parameters

[in, optional] hKeyUser

Type: HKEY

A valid HKEY for a given user. This parameter should be NULL if the function is called in a user's environment, in which case HKEY_CURRENT_USER is used. This parameter should be NULL if the function is called from the SYSTEM context, in which case HKEY_USERS\{SID} is used.

[in, optional] pszMailAddress

Type: LPCTSTR

A pointer to a string in Unicode that specifies the email address of an account belonging to the specified user. When this parameter is NULL, pdwCount returns the total count of unread messages for all accounts owned by the designated user.

[out, optional] pdwCount

Type: DWORD*

Pointer to a DWORD value which receives the unread message count.

[out, optional] pFileTime

Type: FILETIME*

A pointer to a FILETIME structure. The use of this parameter is determined by whether pszMailAddress is NULL. If pszMailAddress is NULL, then this parameter is treated as an [in] parameter, which specifies a filter, so that only unread mail newer than the specified time appears. If pszMailAddress is not NULL, then this parameter is treated as an [out] parameter, which points to a FILETIME structure into which the function places the timestamp of the last SHSetUnreadMailCount call for the specified user and email account.

[out, optional] pszShellExecuteCommand

Type: LPCTSTR

A pointer to a string that returns the ShellExecute command statement passed into the last SHSetUnreadMailCount call for the specified user and email account. This command string starts the email application that owns the account referenced by pszMailAddress. If the ShellExecute command is not required, this parameter can be NULL. If pszMailAddress is NULL, this parameter is ignored and must be NULL.

cchShellExecuteCommand

Type: int

The maximum size, in characters, of the ShellExecute command buffer pointed to by pszShellExecuteCommand. This parameter must be zero for total counts when pszMailAddress is NULL. It can also be NULL whenever the ShellExecute command string is not required.

Return value

Type: HRESULT

If this function succeeds, it returns S_OK. Otherwise, it returns an HRESULT error code.

Requirements

Requirement Value
Minimum supported client Windows XP [desktop apps only]
Minimum supported server Windows Server 2003 [desktop apps only]
Target Platform Windows
Header shellapi.h
Library Shell32.lib
DLL Shell32.dll (version 6.0 or later)