Changing Message Class

Status
Not open for further replies.

srmsrm

Senior Member
Outlook version
Outlook 365 64 bit
Email Account
IMAP
I'm using Outlook 365, W10, not using Exchange. For below, it uses the the default contacts folder (using the name of my form) to change the message class in the defaults contact folder.

How can I update this to select a different contacts folder that is not the default contacts folder to update the message class.

Sub ChangeMessageClass()
Set olNS = Application.GetNamespace("MAPI")
Set ContactsFolder = olNS.GetDefaultFolder(olFolderContacts)
Set ContactItems = ContactsFolder.Items
For Each itm In ContactItems
If itm.MessageClass = "IPM.Contact" Then
itm.MessageClass = "IPM.Contact.Good News Contact"
itm.Save
End If
Next
End Sub

Thank you

Shawn
 
I got it to work in the current folder, but still seeing if I can select another folder.

Sub ChangeMessageClass()
Set olNS = Application.GetNamespace("MAPI")
Set ContactsFolder = Application.ActiveExplorer.CurrentFolder.Items
Set ContactItems = ContactsFolder
For Each Itm In ContactItems
If Itm.MessageClass = "IPM.Contact" Then
Itm.MessageClass = "IPM.Contact.SRM"
Itm.Save
End If
Next
End Sub
 
This : Set ContactsFolder = Application.ActiveExplorer.CurrentFolder.Items
Should be just this: Set ContactsFolder = Application.ActiveExplorer.CurrentFolder

Then use this to set the items - Set ContactItems = ContactsFolder.Items


Selecting the folder first and running it is generally the easiest way to do it - but you can hard code a folder by name
Subfolder of contacts: Set ContactsFolder = olNS.GetDefaultFolder(olFolderContacts).folders("folder name")
Same level as Contacts: Set ContactsFolder = olNS.GetDefaultFolder(olFolderContacts).Parent.folders("Folder name")

 
Diane:

I asked about selecting a folder. What I meant is when I run the Macro I select what folder to use the macro to run on. I don't think I was clear in my question.

I may be misunderstanding your guidance. I tried both versions below and they seem to work the same. They update the message class in the folder I have active (clicked on).

How do they differ and what am I missing?

Set ContactsFolder = Application.ActiveExplorer.CurrentFolder.Items
Set ContactItems = ContactsFolder

Set ContactsFolder = Application.ActiveExplorer.CurrentFolder
Set ContactItems = ContactsFolder.Items

Shawn
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
P Message Class keeps changing back to IPM.Contact Outlook VBA and Custom Forms 2
T Changing Icon of message class Outlook VBA and Custom Forms 1
Diane Poremsky Changing the Message Size in Exchange Server Using Outlook 0
N Creating or changing the main new mail message template in Outlook 2010 Using Outlook 2
L changing view settings based on message body Using Outlook 1
C Outlook Changing Sent Message Headings to SPAM =?UTF-8?B?4Liq4Lij4LmJ4L Using Outlook 1
williamlambton Changing 'To' field in message lists to show SMTP address only. Using Outlook 2
R Changing the default message form in Outlook 2007 Outlook VBA and Custom Forms 1
J Calendar events created on iPhone automatically changing default alert from 'None' to 'Time of Event' Using Outlook.com accounts in Outlook 0
F Auto changing email subject line in bulk Using Outlook 2
K Changing the Deleted Items location in Outlook 2019 Using Outlook 2
MattC Changing the font of an email with VBA Outlook VBA and Custom Forms 1
V Outlook 2021 Can anyone explain why my Outlook views keep changing?! Using Outlook 2
wayneame Changing the Form Used by Existing Task Items in a Folder Outlook VBA and Custom Forms 4
C Pop Server Changing Verizon/Aol to Yahoo Using Outlook 6
P Outlook tasks keeps changing (updating) dates that I type Using Outlook 2
e_a_g_l_e_p_i Changing where data .pst is saved to Using Outlook 3
P Changing the font that the task view shows Using Outlook 5
S Changing colors of today's appointments, but not recurring ones Using Outlook 33
T Changing Sent Items location in Outlook 2019 Using Outlook 0
E Outlook view grouping keeps changing Using Outlook 3
B BCC issues after changing root folder path for gmail Using Outlook 1
M Changing the preferred order for "Put this entry in" list for adding new contacts to the Address Book Using Outlook 1
J Outlook 2010 Changing events in Outlook calendar via opening file, importing CSV Using Outlook 0
A .restrict results changing after moving to Exchange online Outlook VBA and Custom Forms 0
T Outlook Contacts ... Changing Font Size, Style, Bold, etc. Using Outlook 2
N Rule for "on behalf of" - with changing names Using Outlook 2
O Save attachments using hotkey without changing attributes Outlook VBA and Custom Forms 1
M Outlook 2016: Changing default font for Notes and Reading Pane Using Outlook 4
V Changing default date for task follow-up buttons Using Outlook 2
Gary Hile Outlook 2016 changing editor options Using Outlook 6
J Outlook Rules - Changing auto-submit address in multiple rules, according to rule name Outlook VBA and Custom Forms 0
S Problems syncing emails with webmail after changing to Outlook 2016 Using Outlook 1
T Changing default Mail Account in Outlook 2016 - POP3 Using Outlook 1
S Changing notification sound for new incoming messages in Outlook 365/2016 Using Outlook 1
Stephen Weinberg Changing the mailing address checkbox Using Outlook 0
D Outlook 2013 changing iCloud reminder time? Using Outlook 0
C Changing the name of Outlook Messages saved to a folder Using Outlook 1
A Outlook.com changing appointments Using Outlook 8
B Changing CC list to .add Outlook VBA and Custom Forms 2
R changing FW: on forward Outlook VBA and Custom Forms 3
B changing Win7 default backup schedule for Previous Versions Using Outlook 0
Diane Poremsky Changing the default *.pst and *.ost sizes Using Outlook 0
C Macro to send email after changing from address and adding signature Outlook VBA and Custom Forms 1
Diane Poremsky Changing Outlook.com color schemes Using Outlook 0
R Outlook calendar appointments Free/Busy time is changing from "Busy" to "Free" Using Outlook 2
W Changing looks of emails in Outlook 2003 Using Outlook 0
L Office 365 Outlook changing default contact folder Using Outlook 0
Diane Poremsky Changing the From Domain in Office 365 Using Outlook 0
R The changing way to access information in Office 365 Using Outlook 0

Similar threads

Back
Top