PDA

View Full Version : marking copied sent mail as read in outlook



Mechixx
07-14-2016, 07:45 AM
Hello there everyone! This is my first post that I'm hoping to get help on. I've scoured google and looked on this site but couldn't find exactly what i need.

So my dilemma is that in my outlook, i have made sub folders in my sent items folder to categorize different areas at work and suppliers, etc.
i have a rule set up that when i send mail, it makes a copy and puts it in a selected folder according to who i send it to. but when doing this, the copy then becomes unread and the only way to read them is right click and mark folder as read.

I wonder if there's a way i can set up a macro that i can click that marks all these sent folders as read instead of doing it individually, is it possible?

the layout of the sent mail folder is

>Sent items
>>IMT
>>>Folders of different people at work
>>Suppliers
>>>Folders of different suppliers
>>Other
>>>Folders of other misc things.


any help with this would be great!

gmayor
07-14-2016, 10:14 PM
There is no VBA function to mark all items in a folder as read. You would have to mark each individual item, and if your sent items folder is anything like mine, that could take a considerable time to process.

It would be better if you set the read marker when you send the message. You can do this by using a macro rather than rules to copy the messages to the sub folders. Put the following in the ThisOutlookSession module and it will run every time you send a message. Add your recipients to be processed and their various folders. You will almost certainly need to see http://www.gmayor.com/create_and_employ_a_digital_cert.htm


Option Explicit

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim olCopy As MailItem
Dim strFolder As String
If TypeName(Item) = "MailItem" Then
Select Case Item.To
Case Is = "someone@somewhere.com": strFolder = "FolderName"
'add cases and appropriate folder names for each recipient email address to be processed
Case Else: strFolder = ""
End Select
If Not strFolder = "" Then
Set olCopy = Item.Copy
olCopy.UnRead = False
olCopy.Move Session.GetDefaultFolder(olFolderSentMail).folders(strFolder)
End If
End If
lbl_Exit:
Set olCopy = Nothing
Exit Sub
End Sub

Mechixx
07-15-2016, 04:18 AM
ok, ill try this out today sometime!!
So i should delete my rule then and employ this?
and i create as many 'Case Is' lines as it takes for all the people i send messages to? being that i put in their email, and then in the folder name write which folder to put it in?

another thing that comes to mind is, what if the folder is a subfolder of a folder? as long as i call out the name of the sub folder will it still work? for example i have a subfolder 'IMT' under sent items, and then within IMT i have many sub folders for each area at work

gmayor
07-15-2016, 10:16 PM
Yes - create the case statements for each address you want to file, and use instead of the rule(s).

If you want to variously address sub folders and sub folders with further sub folders, the approach needs to be modified slightly to take account of the paths e.g. as follows. If the folders run deeper than two levels concatenate the folders as shown.


Option Explicit

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
Dim olCopy As MailItem
Dim olFolder As Folder
If TypeName(Item) = "MailItem" Then
Select Case Item.To
Case Is = "someone@somewhere.com"
Set olFolder = Session.GetDefaultFolder(olFolderSentMail).folders("FolderName1")
'add cases and appropriate folder names for each recipient email address to be processed
Case Is = "someoneelse@somewhere.com"
Set olFolder = Session.GetDefaultFolder(olFolderSentMail).folders("FolderName1").folders("FolderName2")
Case Is = "yetanothersomeone@somewhere.com"
Set olFolder = Session.GetDefaultFolder(olFolderSentMail).folders("FolderName1").folders("FolderName2").folders("FolderName3")
'add cases and appropriate folder and sub folder names for each recipient email address to be processed
Case Else: Set olFolder = Nothing
End Select
If Not olFolder Is Nothing Then
Set olCopy = Item.Copy
olCopy.UnRead = False
olCopy.Move olFolder
End If
End If
lbl_Exit:
Set olCopy = Nothing
Exit Sub
End Sub

cwager990
02-08-2019, 12:14 PM
Okay this seems to work nicely I have two a few issues though.

Firstly is there anyway to modify this to use wildcards ? so all mail sent to the any user at the domain is copied to the folder specified

Second is there a way to have my display name maintained on the message that is copied.

Lastly can we automate the removal of the message that is being put in the folder specified.

Thanks Chris

cwager990
02-09-2019, 10:16 AM
I asked some questions about this, can anybody help ?