I recently had the same question and found this solution. I hope it helps. Dim oAccount As Outlook.Account dim SentFrom As String if whatever you are checking is true then SentFrom = emailaddress1 else SentFrom = emailaddress2 end if ' Selected Email Account must be a valid Email Account on the PC you are sending the Emails from. For Each oAccount In Application.Session.Accounts If oAccount.SmtpAddress = SentFrom Then mailMail.SendUsingAccount = oAccount Exit For End If Next If mailMail.SendUsingAccount Is Nothing Then msgbox("Account Not Found") end if
|