首页 / 邮件 / 通过c#获取Outlook电子邮件地址
通过c#获取Outlook电子邮件地址
内容导读
互联网集市收集整理的这篇技术教程文章主要介绍了通过c#获取Outlook电子邮件地址,小编现在分享给大家,供广大互联网技能从业者学习和参考。文章包含1838字,纯文字阅读大概需要3分钟。
内容图文
我需要能够使用C#代码获取当前登录用户的电子邮件地址.
我需要完整的地址而不仅仅是假设的电子邮件帐户(例如user@localdomain.com.au),尽管这适用于大多数客户.
任何帮助将不胜感激.
解决方法:
试试这个,从http://msdn.microsoft.com/en-us/library/ff462091.aspx开始:
using System;
using System.Text;
using Outlook = Microsoft.Office.Interop.Outlook;
namespace OutlookAddIn1
{
class Sample
{
public static void DisplayAccountInformation(Outlook.Application application)
{
// The Namespace Object (Session) has a collection of accounts.
Outlook.Accounts accounts = application.Session.Accounts;
// Concatenate a message with information about all accounts.
StringBuilder builder = new StringBuilder();
// Loop over all accounts and print detail account information.
// All properties of the Account object are read-only.
foreach (Outlook.Account account in accounts)
{
// The DisplayName property represents the friendly name of the account.
builder.AppendFormat("DisplayName: {0}\n", account.DisplayName);
// The UserName property provides an account-based context to determine identity.
builder.AppendFormat("UserName: {0}\n", account.UserName);
// The SmtpAddress property provides the SMTP address for the account.
builder.AppendFormat("SmtpAddress: {0}\n", account.SmtpAddress);
// The AccountType property indicates the type of the account.
builder.Append("AccountType: ");
switch (account.AccountType)
{
case Outlook.OlAccountType.olExchange:
builder.AppendLine("Exchange");
break;
case Outlook.OlAccountType.olHttp:
builder.AppendLine("Http");
break;
case Outlook.OlAccountType.olImap:
builder.AppendLine("Imap");
break;
case Outlook.OlAccountType.olOtherAccount:
builder.AppendLine("Other");
break;
case Outlook.OlAccountType.olPop3:
builder.AppendLine("Pop3");
break;
}
builder.AppendLine();
}
// Display the account information.
System.Windows.Forms.MessageBox.Show(builder.ToString());
}
}
}
内容总结
以上是互联网集市为您收集整理的通过c#获取Outlook电子邮件地址全部内容,希望文章能够帮你解决通过c#获取Outlook电子邮件地址所遇到的程序开发问题。 如果觉得互联网集市技术教程内容还不错,欢迎将互联网集市网站推荐给程序员好友。
内容备注
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 gblab@vip.qq.com 举报,一经查实,本站将立刻删除。
内容手机端
扫描二维码推送至手机访问。