Hi,
My macro selects a specific Mailbox account to send the emails but Outlook sends them from another mailbox.
The code is set to send a specific email to different recipients (each email attaches a specific PDF). The problem is the part of the code where I select the mailbox that sends the account:
I have confirmed that the oAccount it selects is the right one, every time. The email is always sent from another account (out of 5 that the user has).
The user has the right oAccount set as default (in position 1) and if I delete the mailbox that is actually sends the emails, it will use another one but not the one selected by the macro.
I have also used the code .sentonbehalfof but it doesn't work either.
thanks in advance,
Jesús
My macro selects a specific Mailbox account to send the emails but Outlook sends them from another mailbox.
The code is set to send a specific email to different recipients (each email attaches a specific PDF). The problem is the part of the code where I select the mailbox that sends the account:
VBA Code:
Sub Send_Emails()
Dim objOutlook As Object
Dim objEmail As Object
Dim oAccount As Outlook.Account
Dim outapp As Outlook.Application
Set objOutlook = New Outlook.Application
Set objEmail = objOutlook.CreateItem(olMailItem)
'Set the text of the email and send it
With objEmail
.To = test_email
Select Case Language
Case "ES"
.Subject = Range("TitleES") & " " & CustomerNum
.Body = Range("BodyES")
.Attachments.Add (Current_Folder & PDF_Letter)
Case "PT"
.Subject = Range("TitlePT") & " " & CustomerNum
.Body = Range("BodyPT")
.Attachments.Add (Current_Folder & PDF_Letter)
End Select
Set oAccount = objOutlook.Session.Accounts.Item(1)
objEmail.SendUsingAccount = oAccount
.Send ' SEND THE MESSAGE.
End With
End Sub
I have confirmed that the oAccount it selects is the right one, every time. The email is always sent from another account (out of 5 that the user has).
The user has the right oAccount set as default (in position 1) and if I delete the mailbox that is actually sends the emails, it will use another one but not the one selected by the macro.
I have also used the code .sentonbehalfof but it doesn't work either.
thanks in advance,
Jesús