Setting the "From" field from within VB

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have little experience writing VB apps but have managed to get an MS Access
(2002) application to auto-send e-mails based upon certain criteria. However,
we have the situation where we would like the e-mails to be sent from a
"functional" e-mail address. All users of the application will have access to
this mail box, some will be directly signed into this mail box and others
will be using it alongside their personal mail box. How can I set the "From"
field in the automated e-mail to be from this "functional" e-mail address?

(As a follow on - is it also possible to avoid the security messages that
come up in Outlook?).
 
I am sorry - could you please be a bit more specific (I have "L" plates
on!")? Where do I look at the property/how do I set it? Is it literally set
to the string of the sending e-mail address? If so, will this work if the
user has Outlook open with the profile of that address?
 
When in doubt about a property, check the object browser: Press ALt+F11 to open the VBA environment in Outlook, then press F2. Switch from <All Libraries> to Outlook to browse all Outlook objects and their properties, methods, and events. Select any object or member, then press F1 to see its Help topic. Or, in Access VBA, add a reference to the Microsoft Outlook library.

You set the property like any other string property of an object, by giving it a value:

objYourMailItem.SentOnBehalfOfName = "some_value"

That value should be the Exchange mailbox alias or address that you want to send from.

If the current user is logged directly into that mailbox as their primary mailbox, there's no need to set From to a different value, but it shouldn't hurt if you do.

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
 
Thanks - I will give this a try. Will this mean that if the recipient replies
it will go to the 'functional' mail box? (Which is what I would like it to
do).
 
Back
Top