How can I use VBA in Excel to select a shared email account for sending an email?

A shared email account has been setup on our Exchange 2013 server.
i have authorisation to send email from this account.

i can't seem to send an email from this account/email address using vba.

i have tried .sentonbehalfof = "account"

any ideas please?

spar-kleOperations DirectorAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

spar-kleOperations DirectorAuthor Commented:
I'm using Excel & Outlook 2010
byundtMechanical EngineerCommented:
Generally I like to test code before posting it. Since I don't have a shared email account on an Exchange 2013 server, I cannot do so, however.

When using VBA to send email from Excel, I invariably follow the code samples posted by Ron de Bruin. This page appears to speak to your problem:

I believe that .SentOnBehalfOfName will send the email from your account, but will make it look as though it is from somebody else and using their email address. I don't believe this is what you want to do.

SendUsingAccount appears to be more of what you were requesting. Please follow the discussion on de Bruin's webpage starting with "Use SendUsingAccount in Excel/Outlook 2007 or higher". Note that there are three steps you must follow:
1. Make sure that you set a reference in the VBA Editor to Outlook 2010
2. Run the Which_Account_Number macro to get a list of email accounts available to you
3. Modify the code in sub Mail_small_Text_Change_Account to send the email

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
spar-kleOperations DirectorAuthor Commented:
Thanks for your reply, really appreciated.

I also often refer to Ron de Bruin's site for emailing from Excel and had checked his site out for this requirement.

Unfortunately the suggestions don't seem to work.
I get a number of the account returned for the main user account, but not for the shared account, so can't select this. That's why I thought I would try .sentonbehalfof

Any other ideas please?
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

byundtMechanical EngineerCommented:
Have you added the Shared account to your Outlook File....Account Settings menu item?

If you haven't, try doing so and then rerun de Bruin's Which_Account_Number macro.
spar-kleOperations DirectorAuthor Commented:

Adding the email account does mean that rondebruin code works, however emails just sit in the outbox of that email account then.
it seems to upset the Exchange settings....??
byundtMechanical EngineerCommented:
Since the Ron de Bruin code is putting the email in the outbox, you have an Outlook/Exchange problem now instead of an Excel VBA one.

Can you send emails from the Shared account using Outlook? If not, perhaps your account setup needs a little tweaking.

I use Outlook, but am by no means an expert on it. If you need help on Outlook setup or Exchange, it would be better to revise the question and post it in those TA so you get help from the right experts.
spar-kleOperations DirectorAuthor Commented:
Yes I think you're right.

I can send emails from the Shared email account, albeit the emails end up in the primary email "Sent Items" folder

Thanks for your help
spar-kleOperations DirectorAuthor Commented:
Thanks for your help, you've been a great help!
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.