Hos Computerworld it-jobbank er vi stolte af at fortsætte det gode partnerskab med folkene bag IT-DAY – efter vores mening Danmarks bedste karrieremesse for unge og erfarne it-kandidater.
Sub AddCategoryColorToEmail() Dim objMail As Outlook.MailItem Dim objCategory As Outlook.Category Dim objNamespace As Outlook.Namespace Dim objIMAPFolder As Outlook.Folder Dim objMailItems As Outlook.Items Dim objMailItem As Object Dim strCategoryName As String Dim strCategoryColor As String
'Get the selected email item Set objMail = Outlook.Application.ActiveExplorer.Selection.Item(1)
'Get the category name and color strCategoryName = "MyCategory" strCategoryColor = "olCategoryColorDarkBlue"
'Get the Outlook Namespace Set objNamespace = Outlook.Application.GetNamespace("MAPI")
'Get the IMAP folder containing the email item Set objIMAPFolder = objNamespace.GetFolderFromID(objMail.Parent.StoreID)
'Get the collection of email items in the folder Set objMailItems = objIMAPFolder.Items
'Find the email item in the collection For Each objMailItem In objMailItems If objMailItem.EntryID = objMail.EntryID Then 'Get the category object Set objCategory = objNamespace.Categories.Item(strCategoryName)
'If the category does not exist, create it If objCategory Is Nothing Then Set objCategory = objNamespace.Categories.Add(strCategoryName, strCategoryColor) End If
'Assign the category to the email item objMailItem.Categories = objMailItem.Categories & ";" & strCategoryName
'Save the changes objMailItem.Save
'Exit the loop Exit For End If Next objMailItem End Sub
Jeg bruger Outlook 2021 - jeg får det ikke til at virke med din kode ?
Synes godt om
Ny brugerNybegynder
Din løsning...
Tilladte BB-code-tags: [b]fed[/b] [i]kursiv[/i] [u]understreget[/u] Web- og emailadresser omdannes automatisk til links. Der sættes "nofollow" på alle links.