Account-Objekt (Outlook)

Das Account-Objekt stellt ein für das aktuelle Profil definiertes Konto dar.

HinwBemerkungeneise

Der Zweck des Accounts-Auflistungsobjekts und des Account-Objekts besteht darin, die Kapazität zum Aufzählen von Account-Objekten in einem bestimmten Profil bereitzustellen, den Typ des Account zu identifizieren und ein bestimmtes Account-Objekt zum Senden von E-Mail zu verwenden.

Hinweis

Helmut Obertanner hat die folgenden Codebeispiele zur Verfügung gestellt. Helmut ist ein Microsoft Most Valuable Professional mit Erfahrung in Microsoft Office-Entwicklungstools in Microsoft Visual Studio und Microsoft Office Outlook.

Beispiel

Die folgenden beiden verwalteten Codebeispiele sind in C# und Visual Basic geschrieben. Um ein verwaltetes Codebeispiel von .NET Framework auszuführen, das ein Component Object Model (COM) aufrufen muss, müssen Sie eine Interopassembly verwenden, die verwaltete Schnittstellen definiert und den COM-Objekten in der Object Model-Typbibliothek zuordnet. Für Outlook können Sie Visual Studio und die Outlook Primary Interop Assembly (PIA) verwenden. Stellen Sie sicher, dass Sie die Outlook 2013 PIA installiert und eine Referenz zur Microsoft Outlook 15.0-Objektbibliothekkomponente in Visual Studio hinzugefügt haben, bevor Sie verwaltete Codebeispiele für Outlook 2013 ausführen. Sie sollten die folgenden Codebeispiele in der ThisAddIn Klasse eines Outlook-Add-Ins (mit Office Developer Tools für Visual Studio) verwenden. Das Objekt der Anwendung im Code muss ein vertrauenswürdiges Outlook- Anwendungsobjekt sein, das von ThisAddIn.Globals bereitgestellt wird. Weitere Informationen zur Verwendung der Outlook-PIA zur Entwicklung verwalteter Outlook-Lösungen finden Sie auf MSDN unter Willkommen bei der Referenz zur primären Interopassembly von Outlook (PIA).

Die Codebeispiele zeigen die DisplayAccountInformation -Methode der -Klasse, die Sample als Teil eines Outlook-Add-In-Projekts implementiert wurde. Jedes Projekt fügt einen Verweis auf die Outlook-PIA hinzu, die auf dem Microsoft.Office.Interop.Outlook-Namespace basiert. Die DisplayAccountInformation-Methode nimmt ein vertrauenswürdiges Outlook- Application-Objekt als Argument an und verwendet das Account -Objekt, um die Details jedes Kontos anzuzeigen, das für das aktuelle Outlook-Profil verfügbar ist.

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()); 
 } 
 } 
}
Imports Outlook = Microsoft.Office.Interop.Outlook 
 
Namespace OutlookAddIn2 
 Class Sample 
 Shared Sub DisplayAccountInformation(ByVal application As Outlook.Application) 
 
 ' The Namespace Object (Session) has a collection of accounts. 
 Dim accounts As Outlook.Accounts = application.Session.Accounts 
 
 ' Concatenate a message with information about all accounts. 
 Dim builder As StringBuilder = New StringBuilder() 
 
 ' Loop over all accounts and print detail account information. 
 ' All properties of the Account object are read-only. 
 Dim account As Outlook.Account 
 For Each account In accounts 
 
 ' The DisplayName property represents the friendly name of the account. 
 builder.AppendFormat("DisplayName: {0}" & vbNewLine, account.DisplayName) 
 
 ' The UserName property provides an account-based context to determine identity. 
 builder.AppendFormat("UserName: {0}" & vbNewLine, account.UserName) 
 
 ' The SmtpAddress property provides the SMTP address for the account. 
 builder.AppendFormat("SmtpAddress: {0}" & vbNewLine, account.SmtpAddress) 
 
 ' The AccountType property indicates the type of the account. 
 builder.Append("AccountType: ") 
 Select Case (account.AccountType) 
 
 Case Outlook.OlAccountType.olExchange 
 builder.AppendLine("Exchange") 
 
 
 Case Outlook.OlAccountType.olHttp 
 builder.AppendLine("Http") 
 
 
 Case Outlook.OlAccountType.olImap 
 builder.AppendLine("Imap") 
 
 
 Case Outlook.OlAccountType.olOtherAccount 
 builder.AppendLine("Other") 
 
 
 Case Outlook.OlAccountType.olPop3 
 builder.AppendLine("Pop3") 
 
 
 End Select 
 
 builder.AppendLine() 
 Next 
 
 
 ' Display the account information. 
 Windows.Forms.MessageBox.Show(builder.ToString()) 
 End Sub 
 
 
 End Class 
End Namespace

Methoden

Name
GetAddressEntryFromID
GetRecipientFromID

Eigenschaften

Name
AccountType
Anwendung
AutoDiscoverConnectionMode
AutoDiscoverXml
Klasse
CurrentUser
DeliveryStore
DisplayName
ExchangeConnectionMode
ExchangeMailboxServerName
ExchangeMailboxServerVersion
Parent
Session
SmtpAddress
UserName

Siehe auch

KontoobjektmitgliederSenden einer E-Mail mit der SMTP-Adresse eines KontosOutlook-Objektmodellreferenz

Support und Feedback

Haben Sie Fragen oder Feedback zu Office VBA oder zu dieser Dokumentation? Unter Office VBA-Support und Feedback finden Sie Hilfestellung zu den Möglichkeiten, wie Sie Support erhalten und Feedback abgeben können.