Solved

How do I change the FROM address in Outlook 2007 using VBA

Posted on 2011-03-17
5
423 Views
Last Modified: 2012-05-11
I have written some VBA code to send an email from Excel 2007 using Outlook.Application and Outlook.MailItem.  My outlook is set up to access my exchange account but I have Send As permission to send from another account.  

Can anyone tell me how to change the From field to the Send As address using VBA.

Thanks
0
Comment
Question by:nicksbell
  • 2
  • 2
5 Comments
 
LVL 76

Accepted Solution

by:
David Lee earned 500 total points
ID: 35156153
Hi, nicksbell.

Assuming that your message is in an object named olkMsg, then

olkMsg.SentOnBehalfOfName = "Some Name"

will work.
0
 
LVL 2

Author Closing Comment

by:nicksbell
ID: 35156296
I had tried that but when the email was displayed the From box was blank so I assumed it didn't work.  However, after your reply I tried sending it and low and behold it worked.

Thanks for your help.
0
 
LVL 6

Expert Comment

by:Russell Lucas
ID: 35156306
I think you use the .SenderEmailAddress property of the mail object.

So:-

obj.SenderEmailAddress = "someone@example.com"
0
 
LVL 76

Expert Comment

by:David Lee
ID: 35156335
You're welcome.
0
 
LVL 2

Author Comment

by:nicksbell
ID: 35156358
SenderEmailAddress is a read-only property.  But its fine, as long as it goes from the right address I'm good.
0

Featured Post

Zoho SalesIQ

Hassle-free live chat software re-imagined for business growth. 2 users, always free.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
This Micro Tutorial demonstrate the bugs in Microsoft Excel for Mac with Pivot Charts.
This Micro Tutorial will demonstrate the scrolling table in Microsoft Excel using the INDEX function.

930 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now