Get Outlook email address through c# -
i need able logged in user's email address c# code.
i need full address , not assumed email account (eg user@localdomain.com.au), although work clients.
any appreciated.
try this, 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) { // namespace object (session) has collection of accounts. outlook.accounts accounts = application.session.accounts; // concatenate message information accounts. stringbuilder builder = new stringbuilder(); // loop on accounts , print detail account information. // properties of account object read-only. foreach (outlook.account account in accounts) { // displayname property represents friendly name of account. builder.appendformat("displayname: {0}\n", account.displayname); // username property provides account-based context determine identity. builder.appendformat("username: {0}\n", account.username); // smtpaddress property provides smtp address account. builder.appendformat("smtpaddress: {0}\n", account.smtpaddress); // accounttype property indicates type of 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 account information. system.windows.forms.messagebox.show(builder.tostring()); } } }
Comments
Post a Comment