[译]Outlook收件箱检查器
By robot-v1.0
本文链接 https://www.kyfws.com/applications/outlook-inbox-checker-zh/
版权声明 本博客所有文章除特别声明外,均采用 BY-NC-SA 许可协议。转载请注明出处!
- 4 分钟阅读 - 1644 个词 阅读量 0[译]Outlook收件箱检查器
原文地址:https://www.codeproject.com/Articles/1062/Outlook-inbox-checker
原文作者:Xavier Dusart
译文由本站 robot-v1.0 翻译
前言
Sample code on how to use tray icons and check Exchange mailbox.
有关如何使用任务栏图标和检查Exchange邮箱的示例代码.
介绍(Introduction)
本文是关于检查新邮件到达Exchange收件箱的信息.由于代码的设计不是很好,因此它不旨在作为"操作方法".您可以将其视为我对这个非常好的网站的贡献.它提供了代码重用的示例以及用于检查邮件的现成应用程序.(This article is about checking new mail arrival in your Exchange inbox. It is not intended as a “how-to”, as the code is not very well designed. You can rather think of it as my contribution to this very good web site. It provides an example of code re-using, and a ready-to-use application for checking mail.)
GUI会说法语.通过编辑对话框,菜单和字符串资源,您可以轻松地将其变成您选择的语言.(GUI speaks French. You can easily turn it into your language of choice, by editing dialog, menu and strings resources.)
它有什么作用?(What does it do?)
MailCheck应用程序使用您的默认配置文件连接到您的Exchange服务器.然后显示一个对话框:(The MailCheck application connects to your Exchange server using your default profile. Then it shows a dialog:)
告诉您是否有新邮件.当您关闭该窗口时,它会在系统托盘中图标化.当收到新邮件时,系统托盘中的图标会更改,并且会发出蜂鸣声.恢复对话框窗口后,新邮件将被视为已检查,并且图标再次更改.托盘图标附带的菜单可运行Outlook.(telling you whether you have new mail or not. When you close that window, it iconizes itself to the system tray. The icon in the system tray changes when new mail arrives, and it beeps. Once you have restored the dialog window, new mail is considered checked, and the icon changes again. A menu attached to the tray icon offers to run Outlook.)
致谢(Acknowledgments)
部分代码来自Microsoft基础类库:Vajira Weerasekera的Wakeme.它涉及所有MAPI东西以连接到Exchange服务器并检查收件箱.(Part of the code comes from Microsoft foundation class library: Wakeme by Vajira Weerasekera. It concerns all the MAPI stuff to connect to your Exchange server and check your inbox.)
该代码的另一部分来自Daniel Zilcsak.您可以阅读他的精彩文章(Another part of the code comes from Daniel Zilcsak. You can read his excellent article) 系统任务栏图标-将您的应用程序最小化到任务栏"(System Tray Icons - Minimize Your Application To Tray") 在这个网站上.(on this site.)
从出色的POP检查器复制了图标(Icons were copied from the excellent POP checker) 魔术邮件监控器(Magic Mail Monitor) 由Valeriy Ovechkin撰写.(by Valeriy Ovechkin.)
丑陋的工作(The ugly work)
我只是遵循Daniel Zilcsak的使用方法指导(I simply followed Daniel Zilcsak’s guidelines on how to use his) CTrayIcon
类.我使用基于对话框的应用程序创建了MFC项目.该应用程序的类是(class. I created my MFC project, using a dialog-based application. The application’s class is) CMailCheckApp
,对话框的类为(, and the dialog’s class is) CMailCheckDlg
.我变了(. I changed) CMailCheckDlg
衍生自(to derive from) CTrayDialog
.(.)
然后我粘贴了微软的样本(Then I glued Microsoft’s sample) CWakemeApp
,并删除了所有与GUI有关的代码.我加了(, and removed all code that concerns GUI. I added a) CMailCheckDlg
成员变量,名为(member variable, named) dlg
, 至(, to) CWakemeApp
,以便在(, so that the dialog gets created when the)若目(Wakeme)应用已创建.最后,(app is created. At last,) theWakeme
CWakemeApp
在以下位置创建应用程序实例(application instance is created in) CMailCheckApp::InitInstance
而不是(instead of the) CMailCheckDlg
和(, and) theWakeme.dlg.DoModal()
叫做.而已 ! (我告诉过你这很丑).当然,我添加了必要的代码来处理GUI.(is called. That’s it ! (I told you it was ugly). Of course, I added the necessary code to handle GUI.)
我唯一真正的贡献就是编码了找到Office应用程序(Outlook)路径的方式.让我们仔细看看这部分,您可能会发现它更有趣:(My only real contribution was to code the way to find the path to an Office application (Outlook). Let’s have a closer look at this part, which you may find more interesting:)
CString CMailCheckDlg::GetOutlookPath()
{
// In case we don't find anything,
// let's try at least default installation path
const CString defaultPath =
"C:\\Program Files\\Microsoft Office\\Office\\Outlook.exe";
HKEY hKey;
TCHAR szCLSID[255];
TCHAR szPath[255];
DWORD dwBufLen = 255;
LONG lRet;
// Find Microsoft's CLSID for Outlook.
// You can also use here Excel.Application,
// Word.Application, etc. Whatever you find in the registry.
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
TEXT("Software\\Classes\\Outlook.Application\\CLSID"),
0,
KEY_QUERY_VALUE,
&hKey) != ERROR_SUCCESS) return defaultPath;
lRet = RegQueryValueEx(hKey,
NULL,
NULL,
NULL,
(LPBYTE)szCLSID,
&dwBufLen);
RegCloseKey(hKey);
if(lRet != ERROR_SUCCESS) return defaultPath;
dwBufLen = 255;
// Now read registry for the CLSID we found.
// Default key under LocalServer32 is
// installation path.
CString key = "Software\\Classes\\CLSID\\"+
CString(szCLSID) +"\\LocalServer32";
if(RegOpenKeyEx(HKEY_LOCAL_MACHINE,
key,
0,
KEY_QUERY_VALUE,
&hKey) != ERROR_SUCCESS) return defaultPath;
lRet = RegQueryValueEx(hKey,
NULL,
NULL,
NULL,
(LPBYTE)szPath,
&dwBufLen);
RegCloseKey(hKey);
if(lRet != ERROR_SUCCESS) return defaultPath;
return szPath;
}
许可
本文以及所有相关的源代码和文件均已获得The Code Project Open License (CPOL)的许可。
C++ VC6 Windows MFC Visual-Studio Dev 新闻 翻译