Partager via


MailItem.SendUsingAccount Property (Outlook)

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

Version Information

Version Added: Outlook 2007

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, then 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 
 
 oMail.SendUsingAccount = oAccount 
 
 oMail.Send 
 
 End If 
 
 Next 
 
End Sub 
 

See Also

Concepts

MailItem Object Members

MailItem Object

How to: Send an E-mail Given the SMTP Address of an Account

Other Resources

How to: Send an E-mail Given the SMTP Address of an Account