Hi Ivan
I'm AnnaThomas and I'd happily help you with your question. In this Forum, we are Microsoft consumers just like yourself no one here is a Microsoft employee.
Here’s an example of how you can modify your code:
Sub SendEmail() Dim OutApp As Outlook.Application Dim OutMail As Outlook.MailItem Dim OutAccount As Outlook.Account
Set OutApp = New Outlook.Application Set OutMail = OutApp.CreateItem(olMailItem)
' Loop through the accounts and find the one to send from For Each OutAccount In OutApp.Session.Accounts If OutAccount.SmtpAddress = "*********************" Then Set OutMail.SendUsingAccount = OutAccount Exit For End If Next
With OutMail . Subject = "Test" . Body = "Test Body" . Recipients.Add ("********************") . Send End With
Set OutMail = Nothing Set OutApp = Nothing End Sub
I hope this helps ;-), let me know if this is contrary to what you need, I would still be helpful to answer more of your questions.
Best Regards,
AnnaThomas
Give back to the community. Help the next person with this problem by indicating whether this answer solved your problem. Click Yes or No at the bottom.