如何从 Outlook 2007 获取发送电子邮件地址
我正在使用 Visual studio 2008 for MS 开发 Outlook 插件项目 C# 中的 Outlook 2007。我在这里解释我的问题...
我的 Outlook 2007 有多个帐户(3 个帐户)。我需要得到 帐户形成新邮件消息窗口中的帐户框。 当我们点击新邮件时,会出现一个新窗口,我们可以从中 发送一封新邮件。在这里(在此窗口上)我们可以看到帐户下拉菜单(左侧 侧)在发送按钮下。如果我们有多个 Outlook 帐户,我们 如果我们点击帐户框,可以在帐户下拉列表中看到所有帐户。如果 我们点击特定的电子邮件,该电子邮件将出现一个正确的标记 在“发送”按钮顶部可以看到帐户和一条消息“This 消息将通过 [email protected]" 发送。
所以,我想将这些电子邮件帐户放入一个字符串中,并且该特定的 电子邮件帐户(有正确的标记)到另一个字符串。 我将这 3 个电子邮件帐户放入一个字符串中。但是,我没有得到 特定的电子邮件帐户(当我们发送新电子邮件时,该帐户具有正确的标记)。
我正在使用这个代码......
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Interop.Outlook;
Outlook._Application myOutlookApp = new Outlook.Application();
Outlook.Accounts myAccounts = myOutlookApp.Session.Accounts;
foreach (Outlook.Account account in myAccounts)
{
string emailAddress = account.SmtpAddress;
}
我可以从上面的代码获取所有帐户......但是,我只想获取我们将用于在特定时刻发送电子邮件的电子邮件地址......
I am working on outlook add-in project using Visual studio 2008 for MS
Outlook 2007 in C#. Here I am explaining my problem...
I got multiple accounts (3 Accounts) with my outlook 2007. I need to get
accounts form Account box in New Mail Message window.
When we click New Mail Message, a new window will appear from which we can
send a new mail. Here (On this window) we can see Account Dropdown (Left
side) under the Send Button. If we have multiple accounts with outlook, we
can see all the accounts in Account Drop Down if we click on Account Box. If
we click on the particular email, a right mark will appear to that Email
Account and a message can bee seen on the top of the Send button is "This
message will be sent via [email protected]".
So, I want to get these email accounts into a string and that particular
email account (which has right mark) into another string.
I got these 3 email accounts into a string. But, I am not getting the
particular email account(which has the right mark when we send a new email).
I am using this code....
using Outlook = Microsoft.Office.Interop.Outlook;
using Office = Microsoft.Office.Core;
using Microsoft.Office.Interop.Outlook;
Outlook._Application myOutlookApp = new Outlook.Application();
Outlook.Accounts myAccounts = myOutlookApp.Session.Accounts;
foreach (Outlook.Account account in myAccounts)
{
string emailAddress = account.SmtpAddress;
}
I am able to get all the accounts from the above code..But, I just want to get the email address which we will use for sending an email at that particular moment..
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
查看 MailItem SendUsingAccount 属性
或者您可以按照您所说的从窗口名称中获取它。
马库斯
Check out MailItem SendUsingAccount property
Or you can grab it from the window name as you say.
Marcus
解决方案很简单:
电子邮件存储在 CurretUser 对象下的 AddressEntry 属性中。该对象已在帐户中 - 多么简单:-)
Solution is easy:
Email is stored in AddressEntry propery, under CurretUser object. That object is under account - how simple :-)