?
Solved

VB code to set the outlook -> Option -> Mailformat -> user microsoft office word 2003 to edit email messages

Posted on 2009-05-12
13
Medium Priority
?
387 Views
Last Modified: 2012-05-06
hi,
im trying to turn the folloiwng option on, with VB code, in outlook (from excel code)

- tools
-- options
---- mail format
----- user microsoft office word 2003 to edit email messages

i have the following code to check if this IS set, however i need to have a way to set it if not, rather then just a msgbox
Set myOlApp = CreateObject("Outlook.Application")
Set MyItem = myOlApp.CreateItem(olMailItem)
Set MyInspector = MyItem.GetInspector
If MyInspector.IsWordMail Then
Else
   'turn it on!!
End If

Open in new window

0
Comment
Question by:jamiepryer
[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
  • 7
  • 6
13 Comments
 
LVL 76

Expert Comment

by:David Lee
ID: 24363758
Hi, jamiepryer.

That is controlled by the following registry setting

HKCU\Software\Microsoft\Office\11.0\Outlook\Options\Mail\EditorPreference

The code below will set the editor as you requested.  You have to do this before Outlook starts or restart Outlook for the change to be seen.
Dim objShell As New WshShell
objShell.RegWrite "HKCU\Software\Microsoft\Office\11.0\Outlook\Options\Mail\EditorPreference", 131073, "REG_DWORD"
Set objShell = Nothing

Open in new window

0
 
LVL 76

Expert Comment

by:David Lee
ID: 24363770
Oops.  The code above is for VBA.  The code below is for VBScript.
Dim objShell
Set objShell = CreateObject("WScript.Shell")
objShell.RegWrite "HKCU\Software\Microsoft\Office\11.0\Outlook\Options\Mail\EditorPreference", 131073, "REG_DWORD"
Set objShell = Nothing

Open in new window

0
 

Author Comment

by:jamiepryer
ID: 24364218
thanks, is there any way to get around this without opening/closing outlook?

My code i run to generate emails seems to work fine, however it randomly seems to bug out after about 150 (ish) emails have been generated and it seems to be because this setting has been turned off?!

any suggestions..
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 76

Expert Comment

by:David Lee
ID: 24364250
How does this setting affect the automated generation of emails?
0
 

Author Comment

by:jamiepryer
ID: 24365012
because my emails are all in richtext and not html
they need to be richtext for some of things i do such as using the word editor to do a find/replace on set items.
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24365170
"they need to be richtext"
The selected editor doesn't control what format items are created in when creating them via code.  That's controlled by the BodyFormat property of each message.
0
 

Author Comment

by:jamiepryer
ID: 24372836
agreed
however if the emails are not richtext, when i add an attachment, it wont be placed within the document.

For attachments:
html emial: just gets added as an "attachment" (shown below hte subject in its own bar)
richtxt email: placed within the email in the location you specify
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24372947
I agree.  How does the editor affect that if the attachments are being inserted by code?  Or are you inserting them manually?
0
 

Author Comment

by:jamiepryer
ID: 24373170
the code add them, i use this to add the attachement and play about with buzz words:


With WordDoc.Range.Find
            .Text = "<Application>"
            .Replacement.Text = ApplicationName
            .Execute Replace:=wdReplaceAll
        End With
        With WordDoc.Range.Find
            ManagerFirstName = Trim(ManagerFirstName)
            .Text = "<Line Manager>"
            .Replacement.Text = ManagerFirstName
            .Execute Replace:=wdReplaceAll
        End With
        With WordDoc.Range.Find
            If CalDate = "" Then
                .Text = " by <Date>"
                .Replacement.Text = ""
                .Execute Replace:=wdReplaceAll
            Else
                .Text = " by <Date>"
                .Replacement.Text = " by " & CalDate
                .Execute Replace:=wdReplaceAll
            End If
        End With
        
        'add the attachment to the document
        Set wdRange = WordDoc.Range
        If wdRange.Find.Execute("<Attachment>") Then
            wdRange.Text = "" 'delete the pilot text
            wdRange.InsertFile TmpString
        End If

Open in new window

0
 
LVL 76

Accepted Solution

by:
David Lee earned 1500 total points
ID: 24403138
We need to check two things.

1.  Is the message format changing?  If the messages are created and the BodyFormat property set to olRTF, then they should be in rich-text format.

2.  Is the Editor Preference setting changing?  If as you say, "... it randomly seems to bug out after about 150 (ish) emails have been generated", then is it because the editor has changed?  To test this, run your process and when it fails go check this setting and see if it has actually changed.  
0
 

Author Comment

by:jamiepryer
ID: 24410079
ok, will do, ive set hte bodyformat to be:    SafeItem.BodyFormat = olFormatRichText

i will test again in the next couple of days nad see where there bug happens
0
 

Author Closing Comment

by:jamiepryer
ID: 31580486
Thanks for the help.
I set hte richtext format and also (as per another question asked) saved all the emails in an archive folder.
I just run the code for 250 emails and its worked fine!
so fingers crossed thats done it :)
0
 
LVL 76

Expert Comment

by:David Lee
ID: 24443796
You're welcome.
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Script to copy or move mouse-selected collection of files plus targets referenced by shortcuts (.lnk) The purpose of this article is to help illuminate the real challenges and options available (where they may exist) for utilizing simple scriptin…
This article is the result of a quest to better understand Task Scheduler 2.0 and all the newer objects available in vbscript in this version over  the limited options we had scripting in Task Scheduler 1.0.  As I started my journey of knowledge I f…
NetCrunch network monitor is a highly extensive platform for network monitoring and alert generation. In this video you'll see a live demo of NetCrunch with most notable features explained in a walk-through manner. You'll also get to know the philos…
How to fix incompatible JVM issue while installing Eclipse While installing Eclipse in windows, got one error like above and unable to proceed with the installation. This video describes how to successfully install Eclipse. How to solve incompa…
Suggested Courses
Course of the Month9 days, 3 hours left to enroll

765 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