Skip to content

SendUsingAccount


Overview

The SendUsingAccount property specifies the account used to send the email message.

Syntax

vba
mailItem.SendUsingAccount

Return Value

An Account object representing the email account used for sending the message.

Example

This example demonstrates how to create a mail item and set the sending account:

vba
Sub SendUsingAccountExample()
    Dim app As New nlsMailer.Application
    Dim mailItem As Object
    Dim currentAccount As Account

    ' Create a new mail item using the Application object
    Set mailItem = app.CreateItem(olMailItem)

    ' Set the sending account
    Set currentAccount = app.Accounts.Add SMTPAddress:="test@example.com", _
                                            ApiKey:="api-key-0123456789", _
                                            ApiUrl:="https://apiUrl.com", _
                                            AccountType:=olMailgun
    mailItem.SendUsingAccount = currentAccount

    Dim selectedAccount As Account
    Set selectedAccount = mailItem.SendUsingAccount

    ' Display account details
    Debug.Print "Sending Account: " & selectedAccount.SMTPAddress
    Debug.Print "Account Type: " & selectedAccount.AccountType
End Sub