I have a problem with my macro for outlook. I've created VBA as below to change default sender email address in Reply , Forward and New Email. I want to use group email as default sender address for all outgoing email. But it can work fine only for New Email. It does not work in Reply and Forward email. Pls kindly help me accordingly.
Code:
Dim WithEvents objInspectors As Outlook.Inspectors
Dim WithEvents objMailItem As Outlook.MailItem
Dim WithEvents myOlExp As Outlook.Explorer
Private Sub Application_Startup()
Initialize_handler
End Sub
Public Sub Initialize_handler()
Set objInspectors = Application.Inspectors
Set myOlExp = Application.ActiveExplorer
End Sub
Private Sub objInspectors_NewInspector(ByVal Inspector As Inspector)
If Inspector.CurrentItem.Class = olMail Then
Set objMailItem = Inspector.CurrentItem
If objMailItem.Sent = False Then
Call SetFromAddress(objMailItem)
End If
End If
End Sub
Public Sub SetFromAddress(oMail As Outlook.MailItem)
oMail.SentOnBehalfOfName = "abc@def.com"
End Sub
Last edited by a moderator: