Link to home
Start Free TrialLog in
Avatar of AlecEriksson
AlecEriksson

asked on

Changing Message Class and Journal Values Programmatically

Hi there, this is a question which at first I figured would be simply a matter of exporting my existing 1700 contacts to an Excel sheet and changing the values, and then importing back into Outlook.  Sadly, not the case at all as it turns out certain internal-use fields in Outlook can not be imported/exported.  And so the problem arises...

How do I go about changing the values of the "Message Class" and "Journal" fields for each of 1700 contacts en masse?  

If someone could walk me through this I would greatly appreciate it!

Thanks!
Avatar of David Lee
David Lee
Flag of United States of America image

Hi AlecEriksson,

You can try this Outlook macro.  Follow these instructions to set it up.
1.  Start Outlook
2.  Click Tools->Macro->Visual Basic Editor
3.  If not already expanded, expand Modules and click on Module1
4.  Copy the code below and paste it into the right-hand pane of the VB Editor
5.  Click the diskette icon on the toolbar to save the changes
6.  Close the VB Editor
7.  Click Tools->Macro->Security
8.  Change the Security Level setting to Medium
9.  Run the macro.  It will loop through all the contacts in the default contacts folder and adjust the Journal and MessageClass settings to whatever values you want to set them to.  I'd recommend making a backup of the contacts folder before you run this.  I'm suggesting that because changing the MessageClass seems dangerous to me.

Sub ChangeContactProperties()
    Dim olkContacts As Outlook.MAPIFolder, _
        olkContact As Object
    Set olkContacts = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderContacts)
    For Each olkContact In olkContacts
        If olkContact.Class = olContact Then
            'Set the value to True or False as desired
            olkContact.Journal = True
            'Set the MessageClass to some value
            olkContact.MessageClass = "???"
            olkContact.Save
        End If
    Next
    Set olkContact = Nothing
    Set olkContacts = Nothing
End Sub

Cheers!
Avatar of AlecEriksson
AlecEriksson

ASKER

Is there a way to make it not use the default contacts folder and instead use a folder path?

Something like \Personal Folders\Import Contacts\?  I tried to change it myself and it doesn't like using a string value instead of an object (from what I can gather about vbscript).
Oh and I also get an error at the For Each line....

"Object does not support property or method"

ASKER CERTIFIED SOLUTION
Avatar of David Lee
David Lee
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Excellent!  It works, albeit slow.  But that's probably just a function of my 1Ghz system and not so much the macro itself.  Heh.

Many thanks for the help, and the in fact changing the MessageClass to something else worked like a charm to force the record to use a new form as I intended.  Works great actually.  Now to set it and let it run over night!
You're welcome.