Getting accounts from Outlook 2007 using VB.NET in VSTO

Posted by Pranav on Geeks with Blogs See other posts from Geeks with Blogs or by Pranav
Published on Tue, 25 May 2010 12:02:53 GMT Indexed on 2010/05/25 12:41 UTC
Read the original article Hit count: 200

Filed under:

This is a sample code for getting Email accounts which are configured in Outlook 2007. This is developed using native code of VSTO. We can also implement is using 3rd party libraries like Redemption.

Dim olAccounts As Outlook.Accounts = Globals.ThisAddIn.Application.ActiveExplorer().Session.Accounts
Dim acc As Outlook.Account
MessageBox.Show(“No. of accounts: ” & olAccounts.Count.ToString)
If olAccounts.Count > 0 Then
ReDim emails(olAccounts.Count)
For Each acc In olAccounts
MessageBox.Show(“Name: ” & acc.UserName & “Email: ” & acc.SmtpAddress)
Marshal.ReleaseComObject(acc)
Next
Else
MessageBox.Show(“There are no accounts in Outlook”)
End If

 Hope this helps!

© Geeks with Blogs or respective owner