Chose e-mail of origin through macro

jonathan_

New Member
Joined
Jul 31, 2013
Messages
2
Hello,

Thank you for this forum, it has been very helpful!

I have a macro that is generating a payment advice from a range in a sheet. This range is included in a separate sheet that and is later used as an attachment of an e-mail in Outlook through macro function below:

Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(0)

However, in outlook I am using four different e-mails depending of the purpose of my e-mail. One personal and three work e-mails. I have seen that if I change the default e-mail on "Start\Settings\Control Panel\Mail\E-mail accounts\Data files" to correct work e-mail (from which I want to send the payment advices) then the e-mail generated from my macro will be sent from this e-mail stored in "Data files".

However this gives me a problem because I have my "To do list" stored in my personal e-mail and not in my work e-mail and when I change the default e-mail in "Data files" it doesn't only change e-mail used in macro but also the "To do list". And my entries are lost until I change back to my personal e-mail in control panel.

Therefore I tried below code:

With OutMail

.to = "hello[at]hello.com"
.from = "myworkemail[at]myworkemail.com" <-----
.Subject = "Hello"
.Attachments.Add ...
.Display
End With

But the .from line didn't work as I expected.

Is there a way to override the default settings in control panel in order to control the e-mail from which message is sent through macro?

Thanks in advance!
Jonathan
 

Excel Facts

Using Function Arguments with nested formulas
If writing INDEX in Func. Arguments, type MATCH(. Use the mouse to click inside MATCH in the formula bar. Dialog switches to MATCH.
Hello

I am far from an expert on this one, but did you try the property "SentOnBehalfOfName" ?
 
Upvote 0
I have searched a bit more regarding this property and I found below thread:

OutlookCode.com :: Send Email with SentonBehalfofName Property

However, as it seems the "From" field is not "read and write" but only "read" by default in Outlook. I found below address with a installable program to "break" open the "From" field. However it's not an option for me, maybe somebody else can take part of solution:

What is Redemption

By now my plan is to add a MsgBox in the end of macro to remind user to change from personal e-mail address to work-email address and then send e-mail manually.

If somebody has a better idea, please let me know.
 
Upvote 0

Forum statistics

Threads
1,216,126
Messages
6,129,020
Members
449,480
Latest member
yesitisasport

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