![]() |
|
|||||||
| Notices |
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Guest
Posts: n/a
|
Archive only 'Read e-mails'
Hi,
Is there a way to defined AutoArchiving to only archive read emails older than a certain period? |
|
|
|
#2 |
|
Guest
Posts: n/a
|
Re: Archive only 'Read e-mails'
Nabeel <> wrote:
> Is there a way to defined AutoArchiving to only archive read emails > older than a certain period? That's exactly what AutoArchive does, with one exception: it doesn't distinguish between read and unread. Any message whose modification date is older than the archive date you choose will be archived. -- Brian Tillman [MVP-Outlook] |
|
|
|
#3 |
|
Guest
Posts: n/a
|
Re: Archive only 'Read e-mails'
One workaround would be to write some VBA code to set the "Do Not
Archive" flag on Read emails, then when you click on File>Archive, uncheck "Include items with "Do not AutoArchive" checked." so those emails would not be moved to archive. HTH, JP On Jan 11, 9:16*am, Nabeel <> wrote: > Hi, > > Is there a way to defined AutoArchiving to only archive read emails > older than a certain period? |
|
|
|
#4 |
|
Guest
Posts: n/a
|
Re: Archive only 'Read e-mails'
I think you meant setting the 'Do Not archive' on 'unread emails'
and then there would be another piece of code to fire on the event when the msg turns to 'read'. anyone who can help with the code? On Jan 12, 1:13*am, JP <> wrote: > One workaround would be to write some VBA code to set the "Do Not > Archive" flag on Read emails, then when you click on File>Archive, > uncheck "Include items with "Do not AutoArchive" checked." so those > emails would not be moved to archive. > > HTH, > JP > > On Jan 11, 9:16*am, Nabeel <> wrote: > > > > > Hi, > > > Is there a way to defined AutoArchiving to only archive read emails > > older than a certain period?- Hide quoted text - > > - Show quoted text - |
|
|
|
#5 |
|
Guest
Posts: n/a
|
Re: Archive only 'Read e-mails'
You may want to post your question in microsoft.*public.*outlook.*
program_vba. To get you started, you would need to check the ItemChange event for your Inbox and see if the "Read" property of an email changes. If it does, set the flag so it won't be archived. This code is a bit crude so hopefully someone else will be able to refine it for you. For example: Private WithEvents Items As Outlook.Items Private Sub Application_Startup() Set Items = objNS.GetDefaultFolder(olFolderInbox).Items End Sub Private Sub Items_ItemChange(ByVal Item As Object) If (Item.Class = olMail) And (Item.UnRead = False) Then On Error Resume Next ' Msgbox "Setting do not archive flag now" Item.NoAging = True On Error Goto 0 End if End Sub HTH, JP On Jan 11, 4:27*pm, Nabeel <> wrote: > I think you meant setting the 'Do Not archive' on 'unread emails' > and then there would be another piece of code to fire on the event > when the msg turns to 'read'. > > anyone who can help with the code? > > On Jan 12, 1:13*am, JP <> wrote: > > > > > One workaround would be to write some VBA code to set the "Do Not > > Archive" flag on Read emails, then when you click on File>Archive, > > uncheck "Include items with "Do not AutoArchive" checked." so those > > emails would not be moved to archive. > > > HTH, > > JP > |
|
|
|
#6 |
|
Guest
Posts: n/a
|
Re: Archive only 'Read e-mails'
Sorry that should be
Private WithEvents Items As Outlook.Items Private Sub Application_Startup() Dim objNS As Outlook.NameSpace Set objNS = Application.GetNamespace("MAPI") Set Items = objNS.GetDefaultFolder(olFolderInbox).Items End Sub Private Sub Items_ItemChange(ByVal Item As Object) If (Item.Class = olMail) And (Item.UnRead = False) Then On Error Resume Next ' Msgbox "Setting do not archive flag now" Item.NoAging = True On Error Goto 0 End if End Sub On Jan 11, 4:41*pm, JP <> wrote: > You may want to post your question in microsoft.*public.*outlook.* > program_vba. |
|
|
|
#7 |
|
Guest
Posts: n/a
|
Re: Archive only 'Read e-mails'
JP <> wrote:
> One workaround would be to write some VBA code to set the "Do Not > Archive" flag on Read emails, then when you click on File>Archive, > uncheck "Include items with "Do not AutoArchive" checked." so those > emails would not be moved to archive. But he wants to archive the read mail. He doesn't want to archive unread mail. The VBA code should add the flag to unread items, not read items. The problem I see with that, though, it that it would be all too esy to forget to reenable archiving on the items as they become read. He's wind up with nothing being archived as messages aged. -- Brian Tillman [MVP-Outlook] |
|
|
|
#8 |
|
Guest
Posts: n/a
|
Re: Archive only 'Read e-mails'
Apparently today is my day to repost code over and over!
I thinkthe double negatives are throwing me off. Thank you Brian, here is the revised (again) code. I do agree with you and suggest something better to the OP, like posting to the other group (or not leaving emails unread <grin>). But as long as the emails are read from the Inbox, wouldn't it trigger this code and (eventually) get the msg archived? Private WithEvents Items As Outlook.Items Private Sub Application_Startup() Dim objNS As Outlook.NameSpace Set objNS = Application.GetNamespace("MAPI") Set Items = objNS.GetDefaultFolder(olFolderInbox).Items End Sub Private Sub Items_ItemChange(ByVal Item As Object) If (Item.Class = olMail) And (Item.UnRead = False) Then On Error Resume Next ' Msgbox "Setting do not archive flag now" Item.NoAging = False Else Item.NoAging = True On Error Goto 0 End if End Sub --JP On Jan 11, 4:51*pm, "Brian Tillman" <tillman1...@yahoo.com> wrote: > > But he wants to archive the read mail. *He doesn't want to archive unread > mail. *The VBA code should add the flag to unread items, not read items. > The problem I see with that, though, it that it would be all too esy to > forget to reenable archiving on the items as they become read. *He's wind up > with nothing being archived as messages aged. > -- > Brian Tillman [MVP-Outlook] |
|
|
|
#9 |
|
Guest
Posts: n/a
|
Re: Archive only 'Read e-mails'
Brian, JP,
Thanks for the code and the suggestion. On Jan 12, 7:03*am, JP <jp2...@earthlink.net> wrote: > Apparently today is my day to repost code over and over! I think> the double negatives are throwing me off. Thank you Brian, here is the > revised (again) code. I do agree with you and suggest something better > to the OP, like posting to the other group (or not leaving emails > unread <grin>). > > But as long as the emails are read from the Inbox, wouldn't it trigger > this code and (eventually) get the msg archived? > > Private WithEvents Items As Outlook.Items > Private Sub Application_Startup() > Dim objNS As Outlook.NameSpace > Set objNS = Application.GetNamespace("MAPI") > Set Items = objNS.GetDefaultFolder(olFolderInbox).Items > End Sub > Private Sub Items_ItemChange(ByVal Item As Object) > If (Item.Class = olMail) And (Item.UnRead = False) Then > * *On Error Resume Next > * *' Msgbox "Setting do not archive flag now" > * *Item.NoAging = False > Else > Item.NoAging = True > * *On Error Goto 0 > End if > End Sub > > --JP > > On Jan 11, 4:51*pm, "Brian Tillman" <tillman1...@yahoo.com> wrote: > > > > > > > But he wants to archive the read mail. *He doesn't want to archive unread > > mail. *The VBA code should add the flag to unread items, not read items. > > The problem I see with that, though, it that it would be all too esy to > > forget to reenable archiving on the items as they become read. *He's wind up > > with nothing being archived as messages aged. > > -- > > Brian Tillman [MVP-Outlook]- Hide quoted text - > > - Show quoted text - |
|
|
|
#10 |
|
Guest
Posts: n/a
|
Re: Archive only 'Read e-mails'
Did you ever refine the code to meet your exact needs? I need the exact same thing :-)
Thanks, Ray |
|
![]() |
| Thread Tools | |
| Display Modes | |
|
|
< Windows Help - MS Office Help - Hardware Support >
| New To Site? | Need Help? |