1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
|
/// <summary>
/// Gets the number of unread mail.
/// </summary>
/// <param name="emailadress">The emailadress.</param>
/// <returns>the number of unread mail</returns>
private static int GetUnreadMailCount(string emailadress)
{
int count = 0;
string unreadkey = String.Format("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\UnreadMail\\{0}", emailadress);
if (!SubKeyExist(unreadkey))
throw new Exception("Subkey does not exist!");
else
{
RegistryKey myKey = Registry.CurrentUser.OpenSubKey(unreadkey);
count = Convert.ToInt32(myKey.GetValue("MessageCount"));
}
return count;
}
/// <summary>
/// Check if the subkey exist.
/// </summary>
/// <param name="Subkey">The subkey.</param>
/// <returns>true or false</returns>
private static bool SubKeyExist(string Subkey)
{
RegistryKey myKey = Registry.CurrentUser.OpenSubKey(Subkey);
return myKey != null;
}
|