A free program from Microsoft that provides developers with the tools, resources, and sandbox environments needed to build solutions for Microsoft 365.
Hi @Elsa Piek
As the Q&A Assistant mentioned, the .From property is not writable. To choose a specific sender, you can use .SendUsingAccount.
Note: The sender account must already exist in the Outlook profile. You can verify this under File > Info > Account Information.
Below is a script that creates a reply and sets a specific account as the sender:
Sub ReplyWithSpecificAccount()
Dim oMail As Outlook.MailItem
Dim oReply As Outlook.MailItem
Dim oAccount As Outlook.Account
Dim sAccountEmail As String
' *** SET YOUR DESIRED SENDER ACCOUNT HERE ***
sAccountEmail = "SpecificYourAccount"
' Get the currently selected email
If Application.ActiveExplorer.Selection.Count = 0 Then
MsgBox "Please select an email to reply to.", vbExclamation
Exit Sub
End If
Set oMail = Application.ActiveExplorer.Selection.Item(1)
' Create the reply
Set oReply = oMail.Reply
' Loop through accounts to find the matching one
Dim accountFound As Boolean
accountFound = False
For Each oAccount In Application.Session.Accounts
If LCase(oAccount.SmtpAddress) = LCase(sAccountEmail) Then
oReply.SendUsingAccount = oAccount
accountFound = True
Exit For
End If
Next oAccount
If Not accountFound Then
MsgBox "Account '" & sAccountEmail & "' not found in Outlook." & vbCrLf & _
"Please check the email address and try again.", vbExclamation
Set oReply = Nothing
Exit Sub
End If
' Display the reply for editing before sending
oReply.Display
' Clean up
Set oReply = Nothing
Set oMail = Nothing
Set oAccount = Nothing
End Sub
Please review this and let me know whether it applies to your situation.
If you need any additional support or have questions, feel free to reach out at any time.
If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.