访问Outlook未读电子邮件给另一个用户 [英] Access outlook unread emails for another user
本文介绍了访问Outlook未读电子邮件给另一个用户的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,
我想使用C#从Inbox访问其他用户的未读电子邮件数(我有用户名和密码)。
我执行的代码为如下:
我的尝试:
private void btnCheck_Click(object sender,EventArgs e)
{
try
{
Microsoft.Office.Interop.Outlook.Application myApp = new Microsoft.Office.Interop.Outlook 。应用();
Microsoft.Office.Interop.Outlook.NameSpace mapiNameSpace = myApp.GetNamespace(MAPI);
mapiNameSpace.Logon(user2,pass2,false,false);
Microsoft.Office.Interop.Outlook.MAPIFolder myInbox = mapiNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox);
int a = myInbox.UnReadItemCount;
txtInbox.Text = Convert.ToString(a);
}
catch(异常错误)
{
MessageBox.Show(err.ToString());
throw;
}
}
在此代码中,我我得到了收件箱的数量。但是我需要user2的收件箱的计数。
解决方案
问题越好,答案越好。
C#Winforms:使用多个邮箱访问Outlook - Stack Overflow [ ^
Hello,
I want to access the unread email count from Inbox for another user (I have the username and password) using C#.
I executed the code as follows:
What I have tried:
private void btnCheck_Click(object sender, EventArgs e) { try { Microsoft.Office.Interop.Outlook.Application myApp = new Microsoft.Office.Interop.Outlook.Application(); Microsoft.Office.Interop.Outlook.NameSpace mapiNameSpace = myApp.GetNamespace("MAPI"); mapiNameSpace.Logon("user2", "pass2", false, false); Microsoft.Office.Interop.Outlook.MAPIFolder myInbox = mapiNameSpace.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox); int a = myInbox.UnReadItemCount; txtInbox.Text = Convert.ToString(a); } catch (Exception err) { MessageBox.Show(err.ToString()); throw; } }
In this code, I am getting the count of my inbox. But I need the count for the user2's inbox.
解决方案
The better the question, the better the answer.
C# Winforms: Accessing Outlook with Multiple Mailboxes - Stack Overflow[^]
这篇关于访问Outlook未读电子邮件给另一个用户的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文