Computer Forums

Member Login

Remember Me? Sign Up! | Forgot Password
 
Slogan
 
Computer Forums > Programmers Lounge > Programming Discussions » How to change a message class in Outlook
Closed Thread
Old 09-24-2004, 09:45 AM   #1 (permalink)
 
Banned

Join Date: May 2003

Posts: 105

imported_Jack

Default How to change a message class in Outlook

I hate to see a forum with no posts so I thought I would post an example of how to change the messageclass of an outlook item.

Use this at your own risk - Changing message classes in Outlook can cause unpredictable results.

Create a form (frmMessageClass) with a command button (cmdProcess), Current Class Label (lblCurrent), status label (lblStatus), text box for new class type (txtNew), label for the default message class of the folder (lblDefault).

**CODE **

Option Explicit
Private ol As Object
Private olns As Object
Private olFolder As Object
Private AllItems As Object
Private Itm As Object
Private NumItems As Integer
Private ItemID As Integer
Private CurFolder As String

Private Sub cmdProcess_Click()
Dim I As Integer
I = 0
If NumItems <> 0 And txtNew <> "" And Right(txtNew, 1) <> "." Then
For Each Itm In AllItems
I = I + 1
'If InStr(1, UCase(Itm.MessageClass), "IPM.CONTACT") <> 0 Then
lblCurrent = Itm.MessageClass
lblStatus = "Updating " & I & " of " & NumItems & "..."
frmMessageClass.Repaint
If Itm.MessageClass <> txtNew Then
Itm.MessageClass = txtNew
Itm.Save
End If
'End If
Next
lblStatus = "Finished processing message classes."
Else
MsgBox "Cannot process request." & Chr(13) & "Either there are no items of this type or the Message Class is missing or ends in a period.", 0, "Change Message Class"
End If
End Sub


Private Sub UserForm_Initialize()
On Error GoTo ErrorHandler
Set ol = New Outlook.Application
Set olns = ol.GetNamespace("MAPI")
Set olFolder = ol.ActiveExplorer.CurrentFolder
CurFolder = olFolder ' get the name of the folder

GoTo Jump
ErrorHandler:
MsgBox "Make sure Outlook is running before running this utility. If Outlook is running, try restarting Outlook and/or your system. If this does not resolve the problem, please reinstall Outlook to re-register the application."
End
Jump:
End Sub


Sub UpdateFolderInfo()
lblDefault = olFolder.DefaultMessageClass
lblCurrent = ""
txtNew = lblDefault
Set AllItems = olFolder.Items
NumItems = AllItems.Count
lblStatus = "Total no. of items:" & Str(NumItems)
End Sub
imported_Jack is offline  
 
Closed Thread

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On