Objeto Account (Outlook)

O objeto Account representa uma conta que é definida para o perfil atual.

Comentários

A finalidade do objeto da coleção contas e o objeto Account é fornecer a capacidade para enumerar os objetos de conta em um determinado perfil, para identificar o tipo de conta e usar um objeto conta específico para enviar email.

Observação

[!OBSERVAçãO] Helmut Obertanner fornecidos os exemplos de código a seguir. Antônio é um Microsoft Most Valuable Professional com experiência nas ferramentas de desenvolvimento do Microsoft Office no Microsoft Office Outlook e no Microsoft Visual Studio.

Exemplo

Os dois exemplos de código gerenciado a seguir são gravados em C# e Visual Basic. To run a .NET Framework managed code sample that needs to call into a Component Object Model (COM), you must use an interop assembly that defines and maps managed interfaces to the COM objects in the object model type library. For Outlook, you can use Visual Studio and the Outlook Primary Interop Assembly (PIA). Before you run managed code samples for Outlook 2013, ensure that you have installed the Outlook 2013 PIA and have added a reference to the Microsoft Outlook 15.0 Object Library component in Visual Studio. Você deve usar os exemplos de código a ThisAddIn seguir na classe de um suplemento do Outlook (usando ferramentas de desenvolvedor do Office para Visual Studio). The Application object in the code must be a trusted Outlook Application object provided by ThisAddIn.Globals. For more information about using the Outlook PIA to develop managed Outlook solutions, see the Outlook 2013 Primary Interop Assembly Reference on MSDN.

Os exemplos de código mostram o DisplayAccountInformation método da Sample classe, implementado como parte de um projeto de suplemento do Outlook. Cada projeto adiciona uma referência para o Outlook PIA, que se baseia no namespace Microsoft.Office.Interop.Outlook. O DisplayAccountInformation método usa como argumento de entrada um objeto confiável do Outlook Application e usa o objeto Account para exibir os detalhes de cada conta disponível para o perfil atual do Outlook.

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

Métodos

Nome
GetAddressEntryFromID
GetRecipientFromID

Propriedades

Nome
AccountType
Application
AutoDiscoverConnectionMode
AutoDiscoverXml
Classe
CurrentUser
DeliveryStore
DisplayName
ExchangeConnectionMode
ExchangeMailboxServerName
ExchangeMailboxServerVersion
Responsável
Sessão
SmtpAddress
UserName

Confira também

Membros do objeto da contaEnviar um email dado o endereço SMTP de uma conta referência demodelo de objeto do Outlook

Suporte e comentários

Tem dúvidas ou quer enviar comentários sobre o VBA para Office ou sobre esta documentação? Confira Suporte e comentários sobre o VBA para Office a fim de obter orientação sobre as maneiras pelas quais você pode receber suporte e fornecer comentários.