Check For Sender or Explicitly State the Sender when sending Outlook Mail From Excel

Hashiru

Active Member
Joined
May 29, 2011
Messages
286
Hi everyone,

I have been using excel to send outlook mail. Now working from outlook default to my personal outlook instead of the work outlook. I will like to modify my code to clearly state the sender in the code

VBA Code:
Sub SendMail()

Dim OApp As Object, EmailMail As Object



Set OApp = CreateObject("Outlook.Application")

Set EmailMail = OApp.createitem(0)



……..

…..

With EmailMail

‘.From = someone@example.com - I will like to explicitly state the sender by either check for the sender property and if it is [EMAIL]Someone@example.com[/EMAIL] then continue otherwise show a messenger "Using wrong or personal email"

.To = Recipient

'.Send

End With

Set EmailMail = Nothing

Set OApp = Nothing

End Sub
 

Excel Facts

Highlight Duplicates
Home, Conditional Formatting, Highlight Cells, Duplicate records, OK to add pink formatting to any duplicates in selected range.
I don't think you can spoof the outlook outgoing, you need to be an account owner to use that ID
 
Upvote 0

Forum statistics

Threads
1,213,549
Messages
6,114,261
Members
448,558
Latest member
aivin

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top