Delete Emails from search results

Status
Not open for further replies.

tu2011

Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server
Hi Everybody.

I'm trying to write a macro to delete all of the emails that come up from a search result and I'm having problem with it. I'm wondering if one of you can give me some assistance.

Here is what I'm doing. I select an email and run the macro which extracts the email address from the selected email, then perform a search for all emails from the same sender within the folder. What I can't figure out is how to programatically select all of those emails and delete them. Here is what I have so far.

Sub FindAllEmailsFromSender()
Dim objMail As Outlook.MailItem
Set objMail = Outlook.Application.ActiveExplorer.Selection.item(1)
Dim strSenderEmailAddr As String
strSenderEmailAddr = objMail.SenderEmailAddress

Dim myOlApp As New Outlook.Application
Set myOlApp.ActiveExplorer.CurrentFolder = Application.ActiveExplorer.CurrentFolder

txtSearch = "from:" & strSenderEmailAddr
myOlApp.ActiveExplorer.Search txtSearch, olSearchScopeCurrentFolder

Set myOlApp = Nothing​
End Sub
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
Retired Geek Outlook on MAC delete duplicate Sent emails Using Outlook 0
D Delete Outlook emails from MS server Using Outlook 17
J Moved many emails to Outlook external folder, need to delete on Gmail server Using Outlook 14
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
O Delete duplicate emails - subscription notifications Using Outlook 5
D Delete Emails from Senders in Shared Mailbox Outlook VBA and Custom Forms 1
J Delete old emails Exchange Server Administration 1
B How to 'really' delete IMAP emails? Using Outlook 6
D Delete selected text from incoming emails Outlook VBA and Custom Forms 25
M Cannot Delete Emails from IMAP inbox Using Outlook 4
T How to send to spam/delete emails with specific heading? Using Outlook 3
J Delete emails older than Using Outlook 1
F Outlook 2010 unable to delete emails from scanner Using Outlook 1
A I have a roaming profile and when I delete emails from one computer Using Outlook 1
A rule to move emails to a folder then want to delete them from that folder 2010 Using Outlook 5
D Outlook 2010 registry hack - delete emails - Google Apps Using Outlook 0
P PST reached maximum size- cant delete emails to slim it down Using Outlook 5
H Macro to Delete Duplicate items in Outlook calendar where title is the same and date is the same Outlook VBA and Custom Forms 0
B Delete Read Receipts in Your Outlook Outlook VBA and Custom Forms 0
A Outlook 365 Delete entries in title field, address book Using Outlook 0
K How can I delete an e-mail from Outlook Using Outlook 1
D Delete selected text in outgoing email body Outlook VBA and Custom Forms 0
E Outlook 365 Save Selected Email Message as .msg File - oMail.Delete not working when SEARCH Outlook VBA and Custom Forms 0
G Automatically delete email when a condition is met Outlook VBA and Custom Forms 1
D Outlook 2021 Using vba code to delete all my spamfolders not only the default one. Outlook VBA and Custom Forms 0
M Shift Delete doesn't delete email from server Using Outlook 3
J Unable to delete folders in Outlook 2019 / Windows Using Outlook 0
Horsepower Cannot delete gmail in iPhone Outlook outbox Using Outlook 1
J Quick steps delete original email and move reply/sent email to folder Using Outlook 2
N How to add or delete items to Move dropdown Menu Using Outlook 0
G Automatically delete messages in the synchronization folder Outlook VBA and Custom Forms 3
O How to delete a forum post? Using Outlook 4
T Outlook 2010 Errore run-time -2147417851 (80010105) Metodo delete ContactItem non riuscito Outlook VBA and Custom Forms 0
C Outlook 2016 Unable to delete Gmail IMAP calendar Using Outlook 2
S Outlook 2016 dont delete inbox item Using Outlook 0
F Wishlist Outlook suddenly began synchronizing deleted items every time I delete a single email. Using Outlook 2
O Outlook 2010 Add delete button to the side of the message list Using Outlook 1
R Outlook 365 update sets delete from server flag Using Outlook 1
S Outlook 2016 A Shortcut to recall and delete and sent message. Using Outlook 1
T Outlook 2010 How to Delete “Orphaned” TO DO? ( Not on Exchange Server) Using Outlook 6
P How did hacker cause link to delete and archive containing email? Using Outlook 6
Z Outlook 365 delete reminder you can’t make change to contents of this-read only folder Using Outlook 4
J To delete the draft email Using Outlook 2
W Recurrence: delete older occurrences / change earliest start time Outlook VBA and Custom Forms 0
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
9 Outlook 2016 How to save an Outlook attachment to a specific folder then delete the email it came from? Using Outlook 1

Similar threads

Back
Top