Solved

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

Posted on 2011-03-17
5
433 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Freeze panes is an option within all variants of Excel to enable parts of a sheet to remain stationary when the cursor is in another part of the sheet. This is a very useful feature which is overlooked or under used.
Read this checklist to learn more about the 15 things you should never include in an email signature.
This Micro Tutorial will demonstrate in Google Sheets how to use the HYPERLINK function to create live links inside your spreadsheet.
This Micro Tutorial will demonstrate in Microsoft Excel how to add style and sexy appeal to horizontal bar charts.

733 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