无法区分 NewMailEx 中的 MailItem 和 MeetingItem

发布于 2024-10-07 21:34:59 字数 765 浏览 0 评论 0原文

我正在使用 C# 开发一个插件。每当我的收件箱中收到任何项目时,我都能收到通知。

    this.Application.NewMailEx += new Outlook.ApplicationEvents_11_NewMailExEventHandler(olApp_NewMail);

 private void olApp_NewMail(String itemCollection)
        {
            string [] strNewItems;
            strNewItems = itemCollection.Split(',');

            foreach (string newItem in strNewItems)
            {                
                Outlook.MailItem mail = (Outlook.MailItem)Application.Session.GetItemFromID(newItem, Type.Missing);
                string old_subj = mail.Subject;
                string old_body = mail.Body;

                MessageBox.Show(old_subj);
            }

        }

但问题是在事件处理程序中,我无法区分它是邮件项目还是会议项目。我该怎么做呢?

提前致谢。

问候, 吉瓦

I am developing an addin using c#. I am able to receive notifications whenever i get any item in my inbox.

    this.Application.NewMailEx += new Outlook.ApplicationEvents_11_NewMailExEventHandler(olApp_NewMail);

 private void olApp_NewMail(String itemCollection)
        {
            string [] strNewItems;
            strNewItems = itemCollection.Split(',');

            foreach (string newItem in strNewItems)
            {                
                Outlook.MailItem mail = (Outlook.MailItem)Application.Session.GetItemFromID(newItem, Type.Missing);
                string old_subj = mail.Subject;
                string old_body = mail.Body;

                MessageBox.Show(old_subj);
            }

        }

but the problem is in the event handler i am not able to distinguish whether it is mail item or meeting item. How should i do it?

thanks in advance.

Regards,
Jeeva

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

灼疼热情 2024-10-14 21:34:59

你能不能做这样的事情:

object item = Application.Session.GetItemFromID(newItem, Type.Missing);
Outlook.MailItem mailItem = item as Outlook.MailItem;
if (mailItem != null)
{
    ...
}
else
{
    Outlook.MeetingItem meetingItem = item as Outlook.MeetingItem;
    if (meetingItem != null)
    {
        ...
    }   
}

Can you not do something like:

object item = Application.Session.GetItemFromID(newItem, Type.Missing);
Outlook.MailItem mailItem = item as Outlook.MailItem;
if (mailItem != null)
{
    ...
}
else
{
    Outlook.MeetingItem meetingItem = item as Outlook.MeetingItem;
    if (meetingItem != null)
    {
        ...
    }   
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文