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?

Thanks
spar-kleOperations DirectorAsked:
Who is Participating?
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
0
byundtCommented:
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: http://www.rondebruin.nl/win/s1/outlook/account.htm

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
0

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?
0
Problems using Powershell and Active Directory?

Managing Active Directory does not always have to be complicated.  If you are spending more time trying instead of doing, then it's time to look at something else. For nearly 20 years, AD admins around the world have used one tool for day-to-day AD management: Hyena. Discover why

byundtCommented:
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.
0
spar-kleOperations DirectorAuthor Commented:
Thanks

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....??
0
byundtCommented:
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.
0
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
0
spar-kleOperations DirectorAuthor Commented:
Thanks for your help, you've been a great help!
0
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
Exchange

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.