#1
|
|||
|
|||
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é" 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. |
#2
|
|||
|
|||
I was able to find out myself, just added
.save behind the assignment Thanks |
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 |
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 |