how to get the default message format using VBA?

  • Thread starter Thread starter news.microsoft.com
  • Start date Start date
N

news.microsoft.com

Hi All,
is it possible to get the default mail format that the user has set using
Tools -> Options -> Mail format?

Sorry. I posted this same note in forms folder too but thought this is more
appropriate folder for my question.

Thanks in advance.
 
Yes you can, via the registry. The settings are as follows (same for Outlook 2002/2003; not sure about prior versions):

HKEY_CURRENT_USER\Software\Microsoft\Office\10.0\Outlook\Options\Mail

Editor Preference

HTML = 131072
HTML & Word To Edit = 131073
Rich Text = 196610
Rich Text & Word To Edit = 196609
Plain Text = 65536
Plain Text & Word To Edit = 65537

UseWordMail = 1 (to read Rich Text Email; key does not exist if never set, 0 if off)
 
Thanks for your response. However there is another issue:

the key is not consistent and changes according to the version installed on
the local machine
like on some machine it could be 9.0, 8.0, 10.0 and may be some other value
in future

Is there any function that would return these values? something that is
associated with the outlook session rather than registry?

Thanks again.


Eric Legault said:
Yes you can, via the registry. The settings are as follows (same for
Outlook 2002/2003; not sure about prior versions):
 
If the values are not available through the Outlook object model (the ones we are discussing aren't), they are either stored in the registry or the file system.

If reading registry values is an issue (the VB GetSetting/SaveSetting functions are restricted to a particular section of the registry), there are plenty of helper classes available on the net. Google "Visual Basic Registry Class" or something similar and you are bound to find some helpful code samples; this would make your life a lot easier versus using the Win32 API registry calls.

--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/
 
What I do in this case is to use code like this:

Dim intOutlookVer as Integer
Dim strOutlookVer as String

intOutlookVer = InStr(Application.Version, ".")
strOutlookVer = Left$(Application.Version, intOutlookVer -
1)

To get the Major version number of the Outlook version.

Once you have that, you can do a Select Case on
the "strOutlookVer" variable, calling your Registry class
with the appropriate key path depending on the version.
You'll need to do your research at www.outlookcode.com or
MSDN to learn the key for each version.
The downside is that you can't be sure of the key for
future versions of Outlook- but if anyone out there has an
algorithm for THAT, I'd like to see it! ;-) So you're
stuck with guessing the key of future versions based on
the current one, and/or issuing updates that you create
after the new versions come out and you know the key.

My favorite Registry class is this one:

http://msdn.microsoft.com/library/default.asp?
url=/library/en-us/dnovba01/html/RegistryMadeEasy.asp

That should be one line, no spaces.

This particular class is very easy to use, handles most
possible errors, and cleans up after itself very well. Its
only drawback is that it doesn't handle binary Registry
data. But that shouldn't be a problem most of the time.
There are other classes out there that handle binary data.


HTH,

-Andrew
======================================================
-----Original Message-----
If the values are not available through the Outlook
object model (the ones we are discussing aren't), they are
either stored in the registry or the file system.
If reading registry values is an issue (the VB
GetSetting/SaveSetting functions are restricted to a
particular section of the registry), there are plenty of
helper classes available on the net. Google "Visual Basic
Registry Class" or something similar and you are bound to
find some helpful code samples; this would make your life
a lot easier versus using the Win32 API registry calls.
--
Eric Legault - B.A, MCP, MCSD, Outlook MVP
--------------------------------------------------
{Private e-mails ignored}
Job: http://www.imaginets.com
Blog: http://blogs.officezealot.com/legault/



news.microsoft.com said:
Thanks for your response. However there is another issue:

the key is not consistent and changes according to the version installed on
the local machine
like on some machine it could be 9.0, 8.0, 10.0 and may be some other value
in future

Is there any function that would return these values? something that is
associated with the outlook session rather than registry?

Thanks again.


"Eric Legault [MVP - Outlook]"
message news:80853B62-68A0-4E9A-9751- (e-mail address removed)... follows (same for
Outlook 2002/2003; not sure about prior versions): not exist if never set,
0 if off) that the user has set
using but thought this is
more
.
 
Back
Top