# Outlook rule with Send from account option



## bencyp (Apr 14, 2011)

Hi, 

I have two email account in Outlook. Email Account A and Email account B. 

I need to write a rule where if I get a mail from account A I should forward those mails from Account B. 

There are third party add-on available that will do this but I just want to know if there is any other way? Those add -on are costly. 

Regards,
Bency


----------



## sobeit (Nov 11, 2007)

there is no reason for an addon - see the following steps

Automatically forward my messages to another e-mail account - Outlook - Microsoft Office

if possible, if you can access the account online, it would be better to change its settings to auto forward to the account you want it to go to.


----------



## bencyp (Apr 14, 2011)

Thanks for your reply. 
Please understand its just not a direct forward. The link you have given shows how to forward a mail. However, in my situation, the mail comes from one mail ID and needs to be forwarded using another email ID. I have two email ID configured in outlook. So, now when I click on forwards I get a button on top which will say From --- this will have two email account and I need to change it manually to another email and click send. 
You cannot set this in a outlook rule.


----------



## RSpecianjr (Jan 20, 2010)

Hey bencyp,

Alright, just to clarify, if you get emails to a certain address you want to forward them to whomever using another address.

If you cannot do this with rules, it is possible to do it with a macro.

Regards,

Robert D. Specian Jr.


----------



## bencyp (Apr 14, 2011)

thanks Robert for your reply. I cannot do it with rule to change the From account. 
I have no idea how to write Macro in Outlook. Can you help me out?


----------



## RSpecianjr (Jan 20, 2010)

Hey bencyp,

I am not terribly good with Outlook macros but I can take a look... unfortunately my weekend is slam packed = / so I wont be able to get anything for you until monday or tuesday.

Perhaps someone else can do it quicker?

Regards,

Robert D. Specian Jr.


----------



## bencyp (Apr 14, 2011)

Hi Robert,
Can you please look into my issue? Need this badly now.


----------



## RSpecianjr (Jan 20, 2010)

Hey bencyp,

If you open outlook and press alt+f11 it will open the VBA editor. You can then expand the menus on the left until you see ThisOutlookSession. Click on that and you will see a blank page on the right. Paste the following code in there:



> Sub RunAScriptRuleRoutine(MyMail As MailItem)
> 
> If Application.ActiveExplorer.Selection.Count Then
> If TypeOf Application.ActiveExplorer.Selection(1) Is Outlook.MailItem Then
> ...


It isn't at all elegant, but it should get it done.

Next step is to create a rule to run a script. Create the rule as normal, but you should have an option on the action to perform settings to run a script. Choose that. It will give you a list of macros that are in your outlook. Sounds like you haven't used them before, so there should only be the one. When you finish the rule, test it out.

Since you have multiple accounts and I am unsure which account was created first etc, you will have to adjust the macro a little bit:

MyMail.SendUsingAccount = Application.Session.Accounts(1)

You can manually change this setting to 

MyMail.SendUsingAccount = Application.Session.Accounts(2)

etc. If you want to see which account is which, you could add something like:

msgbox Application.Session.Accounts(1)

It should pop up with the email address or account name associated to the account.

Like I said, I am no expert on Outlook VBA, so let us know if you run into any problems etc.

Regards,

Robert D. Specian Jr.


----------

