delete Inbox message at specific Hour

Status
Not open for further replies.
N

nina

would someone please post an example of how a message could be deleted from inbox at a

certain hour containing a specific subject string

ie. Hour > 23 and InStr(Subject,"Joined Domain")
 
P

perseeni peppu

Public Sub InboxItemCheck()

Dim myNamespace As Outlook.NameSpace

Dim myAppts As Outlook.Items

Dim myItems As Outlook.Items

Dim myItem As Object

Dim i As Long

Dim DateStart As Date

Dim DateToCheck As String

DateStart = Date

DateToCheck = "[LastModificationTime] >= """ & DateStart & """"

Set myNamespace = Application.GetNamespace("MAPI")

Set myAppts = myNamespace.GetDefaultFolder(olFolderInbox).Items

Set myItems = myAppts.Restrict(DateToCheck)

For i = myItems.Count To 1 Step -1

Set myItem = myItems.Item(i)

If (InStr(myItem.Subject, "Joined Domain")) Then

myItem.Delete

End If

Next

End Sub
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
M Cannot Delete Emails from IMAP inbox Using Outlook 4
R How to delete folders in the inbox.. Using Outlook 1
G I have two mail boxes open, my personal company mail address and a department inbox . When I delete an item from the deparment nbox it goes into the d Using Outlook 1
T Cannot delete single email in INBOX, delete grayed out Using Outlook 7
Z Error code 0x840ccc33__Cannot delete emails from INBOX of MSN Mail - Inbox- MSN Explorer when viewin Using Outlook 2
P Retention Policy Tags (Delete and Allow Recovery) Inbox and Sent Items Exchange Server Administration 2
C Unable to delete messages from Inbox in Outlook 2003, only with my new email address. Using Outlook 1
W OWA 2010: Can't delete messages from inbox Exchange Server Administration 12
B How do I delete all emails in an inbox, all at once, without deleting the inbox itself? Using Outlook 2
G How Do I Keep Outlook 2010 From Going Back To The Inbox After I Delete A Email Using Outlook 2
W Recurrence: delete older occurrences / change earliest start time Outlook VBA and Custom Forms 0
J Moved many emails to Outlook external folder, need to delete on Gmail server Using Outlook 13
A Attachments.Delete Outlook VBA and Custom Forms 3
R Help Revising VBA macro to delete email over different time span Outlook VBA and Custom Forms 0
R Expand VBA Permanent Delete Code Outlook VBA and Custom Forms 6
M Delete headers in Inline reply Outlook VBA and Custom Forms 5
N VBA to delete duplicates by message-id on common pst for 2 or more emails Outlook VBA and Custom Forms 0
S How can I delete all copies of a given companies logo graphic from all my emails at once? Using Outlook 3
9 Outlook 2016 How to save an Outlook attachment to a specific folder then delete the email it came from? Using Outlook 1
D after delete mail, open the next one Outlook VBA and Custom Forms 0
O Delete duplicate emails - subscription notifications Using Outlook 5
F Delete/create/reset Exchange mailbox on Outlook.com Using Outlook.com accounts in Outlook 3
L Email Read and Delete Outlook VBA and Custom Forms 4
H Delete Calendar Entries in Using Outlook 2
D Delete Emails from Senders in Shared Mailbox Outlook VBA and Custom Forms 1
R How to delete Facebook Contacts folder in Outlook 365 Using Outlook 7
R VBA Code to permanently delete selected email Outlook VBA and Custom Forms 10
JoeG Appointment Delete/Change Recurrence Outlook VBA and Custom Forms 0
C Outlook 2016 cannot delete, email showing in root Exchange Server Administration 5
C How to replace or delete first instance of sentence in mail body? Outlook VBA and Custom Forms 1
Z Can't delete IMAP folder Using Outlook 2
J Delete old emails Exchange Server Administration 1
undercover_smother Automatically Forward All Sent Mail and Delete After Send Outlook VBA and Custom Forms 10
T Delete Emails from search results Outlook VBA and Custom Forms 1
I Outlook 2013 How do I delete a Calendar? Using Outlook.com accounts in Outlook 1
N How to delete default folder "Contacts" (olFolderContacts) in a .pst file Using Outlook 8
O How to delete posts New Slipstick.com Articles 1
B How to 'really' delete IMAP emails? Using Outlook 6
H Search and delete part of a link inside HTML body message Outlook VBA and Custom Forms 2
B Delete/replace old files and save new attachments Using Outlook 1
D Delete selected text from incoming emails Outlook VBA and Custom Forms 25
mikolajek Random message selected after hard delete Using Outlook 4
Jeanne Goodman Delete Calendar Item Bypassing Deleted Items folder Outlook VBA and Custom Forms 2
C Delete Subject-Add Organizer to all Reservations in Default Calendar. Using Outlook 0
P Delete mail macro Outlook VBA and Custom Forms 6
B Outlook 2016: Can't delete default calendar but I don't use it Using Outlook 7
O How to delete duplicate RSS messages? Using Outlook 6
J "This item has been changed still want to delete it" message Using Outlook 3
M Can't Delete iCloud Calendar Notifications From Outlook 2016 Using Outlook 0
P Delete Icon Using Outlook 2
Similar threads


















































Top