Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 08-29-2018, 06:13 AM
Senate Senate is offline Outlook not assigning categories Windows 7 32bit Outlook not assigning categories Office 2013
Novice
Outlook not assigning categories
 
Join Date: Jun 2018
Posts: 3
Senate is on a distinguished road
Default Outlook not assigning categories

Hi
I'm using a macro to save attachments to a number of folders as a new email arrives.


To know if Outlook has done his job I would like to assign the category "Treated" to the new Email.
Outlook does in fact save the attachment to the correct folder but it doesn't assign the category.
I post you a glimpse of the code I'm using


Code:
Private Sub Application_NewMail()
     Dim Foldername, FolderDate, FolderDate2, MonthDays As String
     Dim objIn As MAPIFolder
     Dim objNewMail As MailItem
     
     On Error Resume Next
     Set objIn = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox)
     For Each objNewMail In objIn.Items
         With objNewMail
             If .UnRead = True Then
                
                
        ' REGLES SI DES ATTACHEMENTS SONT PRESENTS
                NumberOfAtts = .Attachments.count
                If NumberOfAtts > 0 Then
                    For i = 1 To NumberOfAtts
                
                ' SI ATCT
                        If InStr(1, .Attachments.Item(i).FileName, "ATCT", vbTextCompare) > 0 Then
                            Foldername = "O:\Regions\ST\ATCT\"
                            .Attachments.Item(i).SaveAsFile Foldername & .Attachments.Item(i).FileName
                            '.UnRead = False
                            .Categories = "traité"
                                                                       
                ' SI ATRA
                        ElseIf InStr(1, .Attachments.Item(i).FileName, "ATRA", vbTextCompare) > 0 Then
                            Foldername = "O:\Regions\ST\"
                            FolderDate = .Attachments.Item(i).FileName
                            FolderDate = Mid(FolderDate, InStr(FolderDate, Year(Date) & "-") + 8)
                            FolderDate = Left(FolderDate, InStr(FolderDate, "-") - 1)
                            If Len(FolderDate) = 1 Then
                                FolderDate = "0" & FolderDate
                            End If
                            .Attachments.Item(i).SaveAsFile Foldername & FolderDate & "\ATRA\" & .Attachments.Item(i).FileName
                            '.UnRead = False
                            .Categories = "traité"
And the rest...

Does anyone know why Outlook won't assign a category?

Btw, as I run the macro from VBA directely it assigns the category, but not when the mail arrives and the attachment is saved.
Reply With Quote
  #2  
Old 08-29-2018, 07:53 AM
Senate Senate is offline Outlook not assigning categories Windows 7 32bit Outlook not assigning categories Office 2013
Novice
Outlook not assigning categories
 
Join Date: Jun 2018
Posts: 3
Senate is on a distinguished road
Default

I was able to find out myself, just added
.save
behind the assignment
Thanks
Reply With Quote
Reply

Tags
categories, vba



Similar Threads
Thread Thread Starter Forum Replies Last Post
Assigning Categories to Contacts in Outlook 2007 fjo555 Outlook 0 05-17-2012 11:24 AM
outlook renaming all categories to schedule aircm Outlook 0 05-09-2012 07:45 PM
Outlook 2007: Colour categories CLAWS Outlook 4 12-15-2011 07:33 AM
Outlook not assigning categories Changing phone categories in Outlook Contact cwksr Outlook 1 05-06-2011 08:44 AM
Tools for assigning Categories or Contacts to many items?? Bat Outlook 0 07-05-2007 11:25 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:21 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft