Change the Email id in From field in outlook using VBA

Chandrakanth K

Hello All,


I have code where VBA will attach files and send e-mail to users. But all emails are going through my E-mail ID. i need help to know on how can i change the From address before sending email? Below is my existing code.


Dim olApp As Object
Dim olMail As Object
Dim olRecip As Object
Dim olAtmt As Object
Dim iRow As Long
Dim Recip As String
Dim Subject As String
Dim Atmt As String
Dim sMsgBody As String

iRow = 2

Set olApp = CreateObject("Outlook.Application")

Dim Sht As Worksheet
Set Sht = ThisWorkbook.Worksheets("Sheet1")

Do Until IsEmpty(Sht.Cells(iRow, 1))

Recip = Sht.Cells(iRow, 1).Value
Subject = Sht.Cells(iRow, 2).Value
Atmt = Sht.Cells(iRow, 3).Value ' Attachment Path

Set olMail = olApp.CreateItem(0)

With olMail
Set olRecip = .Recipients.Add(Recip)
.Subject = Subject
.body = sMsgBody
.from = Sht.Range("A3").Value
Set olAtmt = .Attachments.Add(Atmt)
End With

iRow = iRow + 1


Set olApp = Nothing




Related Conversations
Tabs and Dark Mode
cjc2112 in Discussions on
21 Replies
Stable version of Edge insider browser
HotCakeX in Discussions on
35 Replies
flashing a white screen while open new tab
cntvertex in Discussions on
13 Replies
How to Prevent Teams from Auto-Launch
chenrylee in Microsoft Teams on
28 Replies