Changing "From" Email address based upon "To"


Joined
Mar 4, 2012
Messages
3
Reaction score
0
Hello Everyone.

Currently want to build a VBA function that enables people to send emails using a group email address(e.g. person A has an email address (e-mail address removed) and he is also a member of "student" group and has access to send emails using the groups email address (e-mail address removed))

As of now they have to change the From Email address manually searching through many group email address which they usually make mistakes.

I want to automate this by creating a VBA Macro. If the user gets an email from company which has email address ending "@Adidasa.com" I would like the VBA Macro to automatically change the FROM Email address to "(e-mail address removed)"

Currently i have following code which I have found from other sites and a few update from my end. Can anyone help me out with the below and make it working. I am stuck and cannot think of anything else.

Select Code copy to clipboard
Sub CustomMailMessage()

Dim OutApp As Outlook.Application
Dim objOutlookMsg As Outlook.MailItem
Dim objOutlookRecip As Recipient
Dim Recipients As Recipients
Dim OutMail As Object

With OutMail
If objOutlookRecip = "(e-mail address removed)" Then

objOutlookRecip.Type = 1

objOutlookMsg.SentOnBehalfOfName = "(e-mail address removed)"

objOutlookMsg.Subject = "Testing this macro"

objOutlookMsg.HTMLBody = "Testing this macro" & vbCrLf & vbCrLf
End If
End With

'Resolve each Recipient's name.
For Each objOutlookRecip In objOutlookMsg.Recipients
objOutlookRecip.Resolve
Next

'objOutlookMsg.Send
objOutlookMsg.Display

Set OutApp = Nothing

End Sub
 
Ad

Advertisements


Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top