How to figure out the name of Outlook 2007 MailItem fields and how to reference them in VBA

Having a tough time with concepts and how to reference fields...

Someone refered me to MSDN but I am clueless...

I manually fill in the "From:" and "bcc" fields constantly.  I want to set these fields with default values e.g. "abc@xyz.com"

How do I quickly figure out the names of the From and bcc fields, how to reference them, etc...?  I don't know whether to look in the MAPI reference, or the Developer reference, or... (and isn't there an object browser or something like that which can help make it easier?)

Note: to see the "From:" field, you need to set Outlook to display it (same with bcc field):  
To display these fields, create a new e-mail message, select Options; in the Fields section, click on "Show From" and "Show bcc".

I am seeking the lines of code to set these 2 fields of a reply message to "abc@xyz.com"

And if your name is Chris Bottomley, even better ; )
SAbboushiAsked:
Who is Participating?

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

x
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.

Chris BottomleySoftware Quality Lead EngineerCommented:
Is the from you want to use an account established in outlook or something else entirely ... and if something else I have to ask is it legit?

If it is an account in outlook then can do ... if it isn't then not so much but we can set the reply address.

Chris
0
SAbboushiAuthor Commented:
Not an account and yes it is legit ; )

By filling in the From: field manually, it overrides the reply-to e-mail address for the recipient: the recipient sees "From Sam [mailto:Sam@xyz.com] On Behalf Of abc@xyz.com"

When the recipient clicks on 'Reply', the reply-to e-mail address becomes 'abc@xyz.com' even though 'Sam@xyz.com' is 'account' e-mail address

0
Chris BottomleySoftware Quality Lead EngineerCommented:
In that case fine you are looking at the reply to I was thinking about:

See the three modified subs below, the replyrecipients is the same as you show above for on behalf of ... the reply goes in this case to norm"norman.com ... you might want to edit that though ;o)

Chris
Private Sub myItem_ReplyAll(ByVal Response As Object, Cancel As Boolean)
    Response.Subject = Response.Subject & "X"
'    Response.SendUsingAccount = Application.Session.Accounts("me@my.com")
    Response.ReplyRecipients.Add "norm@norman.com"
    Response.BCC = "doris@doris.com"
End Sub

Private Sub myItem_Forward(ByVal Forward As Object, Cancel As Boolean)
    Forward.Subject = Forward.Subject & "X"
'    Response.SendUsingAccount = Application.Session.Accounts("me@my.com")
    Response.ReplyRecipients.Add "norm@norman.com"
    Response.BCC = "doris@doris.com"
End Sub

Private Sub myItem_Reply(ByVal Response As Object, Cancel As Boolean)
    Response.Subject = Response.Subject & "X"
'    Response.SendUsingAccount = Application.Session.Accounts("me@my.com")
    Response.ReplyRecipients.Add "norm@norman.com"
    Response.BCC = "doris@doris.com"
End Sub

Open in new window

0
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!

Chris BottomleySoftware Quality Lead EngineerCommented:
OOPS!

The forward sub is a different object ... corrected here.

Chris
Private Sub myItem_ReplyAll(ByVal Response As Object, Cancel As Boolean)
    Response.Subject = Response.Subject & "X"
'    Response.SendUsingAccount = Application.Session.Accounts("me@mine.com")
    Response.ReplyRecipients.Add "norm@norman.com"
    Response.BCC = "doris@doris.com"
End Sub

Private Sub myItem_Forward(ByVal Forward As Object, Cancel As Boolean)
    Forward.Subject = Forward.Subject & "X"
'    Forward.SendUsingAccount = Application.Session.Accounts("me@mine.com")
    Forward.ReplyRecipients.Add "norm@norman.com"
    Forward.BCC = "doris@doris.com"
End Sub

Private Sub myItem_Reply(ByVal Response As Object, Cancel As Boolean)
    Response.Subject = Response.Subject & "X"
'    Response.SendUsingAccount = Application.Session.Accounts("me@mine.com")
    Response.ReplyRecipients.Add "norm@norman.com"
    Response.BCC = "doris@doris.com"
End Sub

Open in new window

0
SAbboushiAuthor Commented:
Forward button results in 'Object required' run-time error... problem with

    Response.ReplyRecipients.Add "norm@norman.com"

Open in new window


Also, is there a more reliable way to set m_Inspectors?  Any problems (such as this one) requires that I manually run application_startup after I see that the code isn't working anymore

Bigger problem: "From:" field is not being set (bcc works great - thanks!)
0
SAbboushiAuthor Commented:

Found it: Response.SentOnBehalfOfName for "From:" field

Still don't have solution for Forward button...
0
Chris BottomleySoftware Quality Lead EngineerCommented:
replyrecipients ought to work, but forward will be forward.sentonbehalfofname ...

Chris
0
SAbboushiAuthor Commented:
thanks - I will try that

You've made it easier for me by providing the field names - thanks.  Can you tell me how I can find them myself for next time?  My noob approach is highly time-intensive!  

I've read about an object browser & msdn... what is the best resource to help me identify the field references I want (other than Chris!)?   ; )
0
Chris BottomleySoftware Quality Lead EngineerCommented:
You've done fine yourself withsentonbehalf...

In the VBE the object browser is displayed via the F2 key but ... try the models via MS themselves at:

http://msdn.microsoft.com/en-us/library/bb176619(v=office.12).aspx

Chris
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
SAbboushiAuthor Commented:
Great - thanks again!
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
Outlook

From novice to tech pro — start learning today.