none
office365, set category color code? RRS feed

  • Question

  • Hi everyone

    im trying to make a script, for office365. Where it sets a category color for a email. But cant seem to find the code for "category color". Can anyone help me out :) ?

    So in office365, you can change a emails category to a color, like Blue, Green and so on.

    But i want to change it via, Powershell. But cant find the code to do it, dose anyone know how to ?

    Sunday, April 29, 2018 6:08 PM

All replies

  • Are you trying to modify the master category list or and individual Item category? for the master category list you will need to do something like https://social.msdn.microsoft.com/Forums/lync/en-US/0a1e4928-60da-401e-b164-0646e09a6093/ewspowershell-adding-categories-to-a-users-master-category-list-in-exchange-2010?forum=exchangesvrdevelopment

    To set the category on an individual item just modify the Keywords property of the Item

    Cheers
    Glen

    Monday, April 30, 2018 12:01 AM
  • Hi Glen

    So if you look at this picture, its those category im talking about: https://i.imgur.com/xfPQ5tx.jpg

    In the end i want to modify my script, so it dosent move the email from 1 folder to another, but change the category of the files instead, to green, blue or yellow and so on.

    Connect-EXRMailbox -Mailbox "email@domain.com"
    
    ForEach ($message in $messages){
        $MailboxName = $message.email
        $TargetMailbox = $message.TargetMailbox
    
    
         $messageId = $message.MessageId
        $id = $message.Foldername
         New-ExrFolder -displayName $id -FolderClass "IPF.Note" -ParentFolderPath \indbakke -MailboxName $TargetMailbox
         write-host("Processing " + $messageId + " : " + $id)
        $TargetFolder = "\inbox\$id"
        Find-EXRMessageFromMessageId -MailboxName $MailboxName -MessageId $MessageId | ForEach-Object{
            Move-EXRMessage -MailboxName $TargetMailbox -ItemURI $_.ItemRESTURI -TargetFolderPath $TargetFolder
            Write-Host ("Moved Message " + $_.Subject + " to " + $TargetFolder)
        }
    }

    right now, my script moves the emails.

    Monday, April 30, 2018 8:37 AM
  • I have tried edit it a bit to 

    Set-Content 'c:\temp\messageid.csv'
    $messages = Import-Csv -Path c:\temp\messageid.csv
    
    Connect-EXRMailbox -Mailbox "email@domain.com"
    ForEach ($message in $messages){
    $messageId = $message.MessageId
    $messageId.color = "1" 
     
    
    
    }
    But dosent really work. What iam missing ?

    Monday, April 30, 2018 10:10 AM
  • Hi Glen

    I also tried https://social.msdn.microsoft.com/Forums/office/en-US/a3917500-2bbc-4def-98b4-696e49efed6f/adding-categories-to-a-users-master-category-list-in-exchange-2010-using-ews?forum=exchangesvrdevelopment out. but cant get it working.

    Hope you can help me out :) 

    Monday, April 30, 2018 1:14 PM
  • There is currently no code in the Module that would allow you to do an update of the Categories. I've just posted a new version to Powershell gallery and GitHub that should allow that https://www.powershellgallery.com/packages/Exch-Rest/3.6

    So to use it you would do 

    ForEach ($message in $messages){
        $Item = Find-EXRMessageFromMessageId -MailboxName $MailboxName -MessageId $MessageId 
         Set-EXRItemCategory MailboxName $MailboxName -Item $Item -Categories @("Red","Green")
    
    }

    Categories is an array property so you need to pass it in as such so if you just want to set one category use -Categories @("Red")

    Also this doesn't take into account the current Categories that are set on a Message so if you want to maintain those you will need to first enumerate them and then pass the current and new values to Set command else the current values will be overwritten and lost. 

    Cheers
    Glen


    Tuesday, May 1, 2018 1:13 AM
  • Hi Glen

    So i got it working now 

    $messages = Import-Csv -Path c:\temp\messageid.csv
    
    Connect-EXRMailbox -Mailbox "dop@avian.dk"
    ForEach ($message in $messages){
    $MessageId = $message.messageID
    $MailboxName = $message.Email
        $Item = Find-EXRMessageFromMessageId -MailboxName $MailboxName -MessageId $MessageId 
         Set-EXRItemCategory -MailboxName $MailboxName -Item $Item -Categories @("green")
    
    }

    But what it dose, is creating a brand new categorie. How do i to be placed in one of the knowned categorys, like yellow, green and so on? If i just type in green, it makes a brand new category named green.

    I tried to just type in "green category" but then it just create a new one aswell.

    Tuesday, May 1, 2018 6:14 AM
  • Hi Glen.,

    I think i found the error. there was missing a "-" infront of one of the mailboxname.

    $messages = Import-Csv -Path c:\temp\messageid.csv
    
    Connect-EXRMailbox -Mailbox "test@test.com"
    ForEach ($message in $messages){
    $MessageId = $message.messageID
    $MailboxName = $message.Email
        $Item = Find-EXRMessageFromMessageId -MailboxName $MailboxName -MessageId $MessageId 
         Set-EXRItemCategory -MailboxName $MailboxName -Item $Item -Categories @("Green")
    
    }
    But now i got a new error, or  not so mutch a error, more it wont do the job.

    token_type     : Bearer
    scope          : AllSites.Read Bookings.Manage.All Bookings.Read.All Bookings.ReadWrite.All BookingsAppointment.ReadWrite.All Calendars.Read Calendars.Read.All Calendars.Read.Shared Calendars.ReadWrite Calendars.ReadWrite.All 
                     Calendars.ReadWrite.Shared Contacts.Read Contacts.Read.All Contacts.Read.Shared Contacts.ReadWrite Contacts.ReadWrite.All Contacts.ReadWrite.Shared Device.Command Device.Read DeviceManagementApps.Read.All 
                     DeviceManagementApps.ReadWrite.All DeviceManagementConfiguration.Read.All DeviceManagementConfiguration.ReadWrite.All DeviceManagementManagedDevices.PrivilegedOperations.All 
                     DeviceManagementManagedDevices.Read.All DeviceManagementManagedDevices.ReadWrite.All DeviceManagementRBAC.Read.All DeviceManagementRBAC.ReadWrite.All DeviceManagementServiceConfig.Read.All 
                     DeviceManagementServiceConfig.ReadWrite.All Directory.AccessAsUser.All Directory.Read.All Directory.ReadWrite.All EAS.AccessAsUser.All EduAdministration.Read EduAdministration.ReadWrite EduAssignments.Read 
                     EduAssignments.ReadBasic EduAssignments.ReadWrite EduAssignments.ReadWriteBasic EduRoster.Read EduRoster.ReadBasic EduRoster.ReadWrite email Exchange.Manage Files.Read Files.Read.All Files.Read.Selected 
                     Files.ReadWrite Files.ReadWrite.All Files.ReadWrite.AppFolder Files.ReadWrite.Selected Financials.ReadWrite.All full_access_as_user Group.Read.All Group.ReadWrite.All IdentityProvider.Read.All 
                     IdentityProvider.ReadWrite.All IdentityRiskEvent.Read.All Mail.Read Mail.Read.All Mail.Read.Shared Mail.ReadWrite Mail.ReadWrite.All Mail.ReadWrite.Shared Mail.Send Mail.Send.All Mail.Send.Shared 
                     MailboxSettings.Read MailboxSettings.ReadWrite Member.Read.Hidden Notes.Create Notes.Read Notes.Read.All Notes.ReadWrite Notes.ReadWrite.All Notes.ReadWrite.CreatedByApp offline_access openid People.Read 
                     People.Read.All People.ReadWrite profile Reports.Read.All Sites.FullControl.All Sites.Manage.All Sites.Read.All Sites.ReadWrite.All Tasks.Read Tasks.Read.Shared Tasks.ReadWrite Tasks.ReadWrite.Shared 
                     User.Invite.All User.Read User.Read.All User.ReadBasic.All User.ReadWrite User.ReadWrite.All UserTimelineActivity.Write.CreatedByApp
    expires_in     : 3599
    ext_expires_in : 0
    expires_on     : 1525174232
    not_before     : 1525170332
    resource       : https://graph.microsoft.com
    access_token   : System.Security.SecureString
    refresh_token  : System.Security.SecureString
    id_token       : System.Security.SecureString
    clientid       : 5471030d-f311-4c5d-91ef-74ca885463a7
    redirectUrl    : urn%3aietf%3awg%3aoauth%3a2.0%3aoob
    mailbox        : dop@avian.dk
    Cached         : True
    
    @{id=AAMkAGM5NmNiYzU5LWI3NmMtNGY2NC05MzY2LTU1ZWQ0MTM4ZWM4MwBGAAAAAAC_zIG-x5ixRJtFeDeTVF5DBwCtxCqu4tNqTKHb59ufS0GpAAAAAAEMAACtxCqu4tNqTKHb59ufS0GpAACIAKIMAAA=; hasAttachments=; @odata.etag=W/"CQAAABYAAACtxCqu4tNqTKHb59ufS0GpAACIG/n
    8"; inferenceClassification=focused; subject=1; isRead=True; parentFolderId=AAMkAGM5NmNiYzU5LWI3NmMtNGY2NC05MzY2LTU1ZWQ0MTM4ZWM4MwAuAAAAAAC_zIG-x5ixRJtFeDeTVF5DAQCtxCqu4tNqTKHb59ufS0GpAAAAAAEMAAA=; webLink=https://outlook.office36
    5.com/owa/?ItemID=AAMkAGM5NmNiYzU5LWI3NmMtNGY2NC05MzY2LTU1ZWQ0MTM4ZWM4MwBGAAAAAAC%2BzIG%2Fx5ixRJtFeDeTVF5DBwCtxCqu4tNqTKHb59ufS0GpAAAAAAEMAACtxCqu4tNqTKHb59ufS0GpAACIAKIMAAA%3D&exvsurl=1&viewmodel=ReadMessageItem; sender=; receive
    dDateTime=2018-04-30T21:15:25Z; ItemRESTURI=https://graph.microsoft.com/v1.0/users('dop@avian.dk')/messages('AAMkAGM5NmNiYzU5LWI3NmMtNGY2NC05MzY2LTU1ZWQ0MTM4ZWM4MwBGAAAAAAC_zIG-x5ixRJtFeDeTVF5DBwCtxCqu4tNqTKHb59ufS0GpAAAAAAEMAACtx
    Cqu4tNqTKHb59ufS0GpAACIAKIMAAA='); SenderEmailAddress=dop@avian.dk; SenderName=Daniel Oppenlænder} @{id=AAMkAGM5NmNiYzU5LWI3NmMtNGY2NC05MzY2LTU1ZWQ0MTM4ZWM4MwBGAAAAAAC_zIG-x5ixRJtFeDeTVF5DBwCtxCqu4tNqTKHb59ufS0GpAAAAAAEJAACtxCqu4t
    NqTKHb59ufS0GpAACIAOKiAAA=; hasAttachments=; @odata.etag=W/"CQAAABYAAACtxCqu4tNqTKHb59ufS0GpAACIG/oY"; inferenceClassification=focused; subject=1; isRead=True; parentFolderId=AAMkAGM5NmNiYzU5LWI3NmMtNGY2NC05MzY2LTU1ZWQ0MTM4ZWM4MwA
    uAAAAAAC_zIG-x5ixRJtFeDeTVF5DAQCtxCqu4tNqTKHb59ufS0GpAAAAAAEJAAA=; webLink=https://outlook.office365.com/owa/?ItemID=AAMkAGM5NmNiYzU5LWI3NmMtNGY2NC05MzY2LTU1ZWQ0MTM4ZWM4MwBGAAAAAAC%2BzIG%2Fx5ixRJtFeDeTVF5DBwCtxCqu4tNqTKHb59ufS0GpA
    AAAAAEJAACtxCqu4tNqTKHb59ufS0GpAACIAOKiAAA%3D&exvsurl=1&viewmodel=ReadMessageItem; sender=; receivedDateTime=2018-04-30T21:15:26Z; ItemRESTURI=https://graph.microsoft.com/v1.0/users('dop@avian.dk')/messages('AAMkAGM5NmNiYzU5LWI3Nm
    MtNGY2NC05MzY2LTU1ZWQ0MTM4ZWM4MwBGAAAAAAC_zIG-x5ixRJtFeDeTVF5DBwCtxCqu4tNqTKHb59ufS0GpAAAAAAEJAACtxCqu4tNqTKHb59ufS0GpAACIAOKiAAA='); SenderEmailAddress=dop@avian.dk; SenderName=Daniel Oppenlænder}
    StatusCode: 400, ReasonPhrase: 'Bad Request', Version: 1.1, Content: System.Net.Http.StreamContent, Headers:
    {
      Transfer-Encoding: chunked
      request-id: 2069da04-f2b7-495d-9145-bd67d4b366d4
      client-request-id: 2069da04-f2b7-495d-9145-bd67d4b366d4
      x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"West Europe","Slice":"SliceA","Ring":"5","ScaleUnit":"001","Host":"AGSFE_IN_39","ADSiteName":"AMS"}}
      Duration: 82.0627
      Strict-Transport-Security: max-age=31536000
      Cache-Control: private
      Date: Tue, 01 May 2018 10:30:32 GMT
      Content-Type: application/json
    }
    Result                 : {
                               "error": {
                                 "code": "UnknownError",
                                 "message": "<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01//EN\"\"http://www.w3.org/TR/html4/strict.dtd\">\r\n<HTML><HEAD><TITLE>Bad Request</TITLE>\r\n<META HTTP-EQUIV=\"Content-Type\" 
                             Content=\"text/html; charset=us-ascii\"></HEAD>\r\n<BODY><h2>Bad Request - Invalid URL</h2>\r\n<hr><p>HTTP Error 400. The request URL is invalid.</p>\r\n</BODY></HTML>\r\n",
                                 "innerError": {
                                   "request-id": "2069da04-f2b7-495d-9145-bd67d4b366d4",
                                   "date": "2018-05-01T10:30:32"
                                 }
                               }
                             }
    Id                     : 123732
    Exception              : 
    Status                 : RanToCompletion
    IsCanceled             : False
    IsCompleted            : True
    CreationOptions        : None
    AsyncState             : 
    IsFaulted              : False
    AsyncWaitHandle        : System.Threading.ManualResetEvent
    CompletedSynchronously : False
    
    Error making REST Patch BadRequest : Bad Request
    Version             : 1.1
    Content             : System.Net.Http.StreamContent
    StatusCode          : BadRequest
    ReasonPhrase        : Bad Request
    Headers             : {[Transfer-Encoding, System.String[]], [request-id, System.String[]], [client-request-id, System.String[]], [x-ms-ags-diagnostic, System.String[]]...}
    RequestMessage      : Method: PATCH, RequestUri: 'https://graph.microsoft.com/v1.0/users('dop@avian.dk')/MailFolders/AllItems/messages('AAMkAGM5NmNiYzU5LWI3NmMtNGY2NC05MzY2LTU1ZWQ0MTM4ZWM4MwBGAAAAAAC_zIG-x5ixRJtFeDeTVF5DBwCtxCqu4
                          tNqTKHb59ufS0GpAAAAAAEMAACtxCqu4tNqTKHb59ufS0GpAACIAKIMAAA= 
                          AAMkAGM5NmNiYzU5LWI3NmMtNGY2NC05MzY2LTU1ZWQ0MTM4ZWM4MwBGAAAAAAC_zIG-x5ixRJtFeDeTVF5DBwCtxCqu4tNqTKHb59ufS0GpAAAAAAEJAACtxCqu4tNqTKHb59ufS0GpAACIAOKiAAA=')', Version: 1.1, Content: 
                          System.Net.Http.StringContent, Headers:
                          {
                            Accept: application/json
                            X-AnchorMailbox: dop@avian.dk
                            User-Agent: RestClient/1.1
                            Authorization: Bearer eyJ0eXAiOiJKV1QiLCJub25jZSI6IkFRQUJBQUFBQUFEWDhHQ2k2SnM2U0s4MlRzRDJQYjdyTjRiSXhYVzFJbmFuUnRhYVJ6UHJKZm9EVU1oeEpZNVp0Zlo2RjdRalBPNVZiLVJqbGVKbWpYdmJQVktBc0tndHBmNFg4OVRteXZ0Tkt1b2ZRTVJ
                          nMHlBQSIsImFsZyI6IlJTMjU2IiwieDV0IjoiRlNpbXVGckZOb0Mwc0pYR212MTNuTlpjZURjIiwia2lkIjoiRlNpbXVGckZOb0Mwc0pYR212MTNuTlpjZURjIn0.eyJhdWQiOiJodHRwczovL2dyYXBoLm1pY3Jvc29mdC5jb20iLCJpc3MiOiJodHRwczovL3N0cy53aW5kb3
                          dzLm5ldC9iMTg3NWNkOC1hMzliLTQxYzctYTRhOC02MDFmNDNjNWEyMTIvIiwiaWF0IjoxNTI1MTcwMzMyLCJuYmYiOjE1MjUxNzAzMzIsImV4cCI6MTUyNTE3NDIzMiwiYWNyIjoiMSIsImFpbyI6IkFWUUFxLzhIQUFBQURaWExTOHlpVmJURFJpdXZ6MFJELzZVRG13MHcvR
                          jVPdHo0dk0vQTR6UDZSNFZrL2cwVW5iSGV1cTRpMUNudVNwUUxDT04yWktDTlBVcnVrZHpDZU1QS3VLZDJ0RDgrKzBOcFJnV0dwTytJPSIsImFtciI6WyJwd2QiLCJtZmEiXSwiYXBwX2Rpc3BsYXluYW1lIjoiRXhjaC1SRVNUIFBvd2Vyc2hlbGwgTW9kdWxlIFJlZ2lzdHJh
                          dGlvbiBGdWxsIEFjY2VzcyIsImFwcGlkIjoiNTQ3MTAzMGQtZjMxMS00YzVkLTkxZWYtNzRjYTg4NTQ2M2E3IiwiYXBwaWRhY3IiOiIwIiwiZmFtaWx5X25hbWUiOiJPcHBlbmzDpm5kZXIiLCJnaXZlbl9uYW1lIjoiRGFuaWVsIiwiaXBhZGRyIjoiMjEyLjEwLjE3Mi4yMzE
                          iLCJuYW1lIjoiRGFuaWVsIE9wcGVubMOmbmRlciIsIm9pZCI6IjQ2ZGFkYWVjLTUzZjYtNDI4My1hMzkwLTE4ZTlhZmVkMTlhMSIsInBsYXRmIjoiMyIsInB1aWQiOiIxMDAzQkZGREE1MkU1NkQ0Iiwic2NwIjoiQWxsU2l0ZXMuUmVhZCBCb29raW5ncy5NYW5hZ2UuQWxsIE
                          Jvb2tpbmdzLlJlYWQuQWxsIEJvb2tpbmdzLlJlYWRXcml0ZS5BbGwgQm9va2luZ3NBcHBvaW50bWVudC5SZWFkV3JpdGUuQWxsIENhbGVuZGFycy5SZWFkIENhbGVuZGFycy5SZWFkLkFsbCBDYWxlbmRhcnMuUmVhZC5TaGFyZWQgQ2FsZW5kYXJzLlJlYWRXcml0ZSBDYWxlb
                          mRhcnMuUmVhZFdyaXRlLkFsbCBDYWxlbmRhcnMuUmVhZFdyaXRlLlNoYXJlZCBDb250YWN0cy5SZWFkIENvbnRhY3RzLlJlYWQuQWxsIENvbnRhY3RzLlJlYWQuU2hhcmVkIENvbnRhY3RzLlJlYWRXcml0ZSBDb250YWN0cy5SZWFkV3JpdGUuQWxsIENvbnRhY3RzLlJlYWRX
                          cml0ZS5TaGFyZWQgRGV2aWNlLkNvbW1hbmQgRGV2aWNlLlJlYWQgRGV2aWNlTWFuYWdlbWVudEFwcHMuUmVhZC5BbGwgRGV2aWNlTWFuYWdlbWVudEFwcHMuUmVhZFdyaXRlLkFsbCBEZXZpY2VNYW5hZ2VtZW50Q29uZmlndXJhdGlvbi5SZWFkLkFsbCBEZXZpY2VNYW5hZ2V
                          tZW50Q29uZmlndXJhdGlvbi5SZWFkV3JpdGUuQWxsIERldmljZU1hbmFnZW1lbnRNYW5hZ2VkRGV2aWNlcy5Qcml2aWxlZ2VkT3BlcmF0aW9ucy5BbGwgRGV2aWNlTWFuYWdlbWVudE1hbmFnZWREZXZpY2VzLlJlYWQuQWxsIERldmljZU1hbmFnZW1lbnRNYW5hZ2VkRGV2aW
                          Nlcy5SZWFkV3JpdGUuQWxsIERldmljZU1hbmFnZW1lbnRSQkFDLlJlYWQuQWxsIERldmljZU1hbmFnZW1lbnRSQkFDLlJlYWRXcml0ZS5BbGwgRGV2aWNlTWFuYWdlbWVudFNlcnZpY2VDb25maWcuUmVhZC5BbGwgRGV2aWNlTWFuYWdlbWVudFNlcnZpY2VDb25maWcuUmVhZ
                          FdyaXRlLkFsbCBEaXJlY3RvcnkuQWNjZXNzQXNVc2VyLkFsbCBEaXJlY3RvcnkuUmVhZC5BbGwgRGlyZWN0b3J5LlJlYWRXcml0ZS5BbGwgRUFTLkFjY2Vzc0FzVXNlci5BbGwgRWR1QWRtaW5pc3RyYXRpb24uUmVhZCBFZHVBZG1pbmlzdHJhdGlvbi5SZWFkV3JpdGUgRWR1
                          QXNzaWdubWVudHMuUmVhZCBFZHVBc3NpZ25tZW50cy5SZWFkQmFzaWMgRWR1QXNzaWdubWVudHMuUmVhZFdyaXRlIEVkdUFzc2lnbm1lbnRzLlJlYWRXcml0ZUJhc2ljIEVkdVJvc3Rlci5SZWFkIEVkdVJvc3Rlci5SZWFkQmFzaWMgRWR1Um9zdGVyLlJlYWRXcml0ZSBlbWF
                          pbCBFeGNoYW5nZS5NYW5hZ2UgRmlsZXMuUmVhZCBGaWxlcy5SZWFkLkFsbCBGaWxlcy5SZWFkLlNlbGVjdGVkIEZpbGVzLlJlYWRXcml0ZSBGaWxlcy5SZWFkV3JpdGUuQWxsIEZpbGVzLlJlYWRXcml0ZS5BcHBGb2xkZXIgRmlsZXMuUmVhZFdyaXRlLlNlbGVjdGVkIEZpbm
                          FuY2lhbHMuUmVhZFdyaXRlLkFsbCBmdWxsX2FjY2Vzc19hc191c2VyIEdyb3VwLlJlYWQuQWxsIEdyb3VwLlJlYWRXcml0ZS5BbGwgSWRlbnRpdHlQcm92aWRlci5SZWFkLkFsbCBJZGVudGl0eVByb3ZpZGVyLlJlYWRXcml0ZS5BbGwgSWRlbnRpdHlSaXNrRXZlbnQuUmVhZ
                          C5BbGwgTWFpbC5SZWFkIE1haWwuUmVhZC5BbGwgTWFpbC5SZWFkLlNoYXJlZCBNYWlsLlJlYWRXcml0ZSBNYWlsLlJlYWRXcml0ZS5BbGwgTWFpbC5SZWFkV3JpdGUuU2hhcmVkIE1haWwuU2VuZCBNYWlsLlNlbmQuQWxsIE1haWwuU2VuZC5TaGFyZWQgTWFpbGJveFNldHRp
                          bmdzLlJlYWQgTWFpbGJveFNldHRpbmdzLlJlYWRXcml0ZSBNZW1iZXIuUmVhZC5IaWRkZW4gTm90ZXMuQ3JlYXRlIE5vdGVzLlJlYWQgTm90ZXMuUmVhZC5BbGwgTm90ZXMuUmVhZFdyaXRlIE5vdGVzLlJlYWRXcml0ZS5BbGwgTm90ZXMuUmVhZFdyaXRlLkNyZWF0ZWRCeUF
                          wcCBvZmZsaW5lX2FjY2VzcyBvcGVuaWQgUGVvcGxlLlJlYWQgUGVvcGxlLlJlYWQuQWxsIFBlb3BsZS5SZWFkV3JpdGUgcHJvZmlsZSBSZXBvcnRzLlJlYWQuQWxsIFNpdGVzLkZ1bGxDb250cm9sLkFsbCBTaXRlcy5NYW5hZ2UuQWxsIFNpdGVzLlJlYWQuQWxsIFNpdGVzLl
                          JlYWRXcml0ZS5BbGwgVGFza3MuUmVhZCBUYXNrcy5SZWFkLlNoYXJlZCBUYXNrcy5SZWFkV3JpdGUgVGFza3MuUmVhZFdyaXRlLlNoYXJlZCBVc2VyLkludml0ZS5BbGwgVXNlci5SZWFkIFVzZXIuUmVhZC5BbGwgVXNlci5SZWFkQmFzaWMuQWxsIFVzZXIuUmVhZFdyaXRlI
                          FVzZXIuUmVhZFdyaXRlLkFsbCBVc2VyVGltZWxpbmVBY3Rpdml0eS5Xcml0ZS5DcmVhdGVkQnlBcHAiLCJzdWIiOiI3M3JnMjc4QUFUbW5TRk1LTlcxSElhN25ld240blRZR2xhWjVLdjZxWXFRIiwidGlkIjoiYjE4NzVjZDgtYTM5Yi00MWM3LWE0YTgtNjAxZjQzYzVhMjEy
                          IiwidW5pcXVlX25hbWUiOiJkb3BAYXZpYW4uZGsiLCJ1cG4iOiJkb3BAYXZpYW4uZGsiLCJ1dGkiOiI2clJsMU9JUkxVYVFrSEZUb1hRbEFBIiwidmVyIjoiMS4wIiwid2lkcyI6WyI2MmU5MDM5NC02OWY1LTQyMzctOTE5MC0wMTIxNzcxNDVlMTAiXX0.PVbrljxKwRmeHKH
                          IMdjVWjCdtqHY4_XFscsCF7fT4kHhs2EOm33jJiHn8VI3kfTB3kguVIP0rqgi-dKjbp4XD3uujssZeYWb78_ELsUYgqfNhkNXHNNeeOmqrqWOFt5DwJiqTojKClV1R3A94K9_z33TU3yFQBZ4De1gFVYKSBFmYR0wdMaPcSdQJnctKqnI_blmB1jbUPyJp3CB4NxfXf0F64YCuG
                          EHgz6QIynBfHMMuSNkwW7zepjqvVazFrWxpVhd4F75cxuWatMwkjMw28QxBgf33YmF1SVjaPkjyfhYHEFU0EJ2cObE-u7hBQM1-RLvy2QVj_rOuEofCSOYxA
                            Content-Type: application/json; charset=utf-8
                            Content-Length: 28
                          }
    IsSuccessStatusCode : False


    Tuesday, May 1, 2018 10:32 AM
  • Try replacing the contents of \Exch-Rest\functions\mailItems\Set-EXRItemCategory with

    function Set-EXRItemCategory {
        [CmdletBinding()]
        param (
    
            [parameter(ValueFromPipeline = $True)]
            [psobject[]]$Item,
    		
            [Parameter(Position = 0, Mandatory = $false)]
            [string]
            $MailboxName,
    
            [Parameter(Position = 2, Mandatory = $false)]
            [String]
            $ItemId,
    		
            [Parameter(Position = 3, Mandatory = $false)]
            [psobject]
            $AccessToken,
    
            [Parameter(Position = 4, Mandatory = $false)]
            [Object[]]
            $Categories	
            
            
        )
        Process {
            Write-Host $Item
            if ($AccessToken -eq $null) {
                $AccessToken = Get-ProfiledToken -MailboxName $MailboxName  
                if ($AccessToken -eq $null) {
                    $AccessToken = Get-EXRAccessToken -MailboxName $MailboxName       
                }                 
            }
            if ([String]::IsNullOrEmpty($MailboxName)) {
                $MailboxName = $AccessToken.mailbox
            } 
            $HttpClient = Get-HTTPClient -MailboxName $MailboxName
            $EndPoint = Get-EndPoint -AccessToken $AccessToken -Segment "users"
            $RequestURL = $EndPoint + "('" + $MailboxName + "')/messages"
            if ($Item -eq $null) {
                $RequestURL = $EndPoint + "('" + $MailboxName + "')/messages" + "('" + $ItemId + "')"
            }
            else {
                $RequestURL = $EndPoint + "('" + $MailboxName + "')/messages" + "('" + $Item.Id + "')"
            }
            $Update = "{`r`n`"categories`":["
            $first = $true
            foreach ($Item in $Categories) {
                if (!$first) {
                    $Update += ",`r`n"
                }
                else {$first = $false}        
                $Update += "`"" + $Item + "`""
            }
            $Update += "]}`r`n"
            return Update-EXRItem -ItemURI $RequestURL -MailboxName $MailboxName -AccessToken $AccessToken -details $Update
        }
    }
    The category is just a plain text keyword that must match whatever you have in the master category list of the Mailbox you working on eg whatever is in the name property Orange category etc. This won't modify the Master category list at all it will only add a keyword to the Mail item in question and for that to show as a color in Outlook it must match an entry in the user Master category list.

    Tuesday, May 1, 2018 9:22 PM