Muokkaa

Jaa


MailItem.SendUsingAccount property (Outlook)

Returns or sets an Account object that represents the account under which the MailItem is to be sent. Read/write.

Syntax

expression. SendUsingAccount

expression An expression that returns a MailItem object.

Remarks

The SendUsingAccount property can be used to specify the account that should be used to send the MailItem when the Send method is called. This property returns Null (Nothing in Visual Basic) if the account specified for the MailItem no longer exists.

Example

The following code sample in Microsoft Visual Basic for Applications enumerates the Accounts collection to find a Pop3 account. If the account is found, a message is created programmatically, and the SendUsingAccount property is assigned to the Pop3 account. Note that you must assign the SendUsingAccount property before you call the Send method.

Sub SendUsingAccount() 
 
 Dim oAccount As Outlook.account 
 
 For Each oAccount In Application.Session.Accounts 
 
 If oAccount.AccountType = olPop3 Then 
 
 Dim oMail As Outlook.MailItem 
 
 Set oMail = Application.CreateItem(olMailItem) 
 
     oMail.Subject = "Sent using POP3 Account" 
 
     oMail.Recipients.Add ("someone@example.com") 
 
     oMail.Recipients.ResolveAll 
 
 Set oMail.SendUsingAccount = oAccount 
 
     oMail.Send 
 
 End If 
 
 Next 
 
End Sub

See also

Support and feedback

Have questions or feedback about Office VBA or this documentation? Please see Office VBA support and feedback for guidance about the ways you can receive support and provide feedback.