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
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
N Delete non working emails from contacts Outlook Wishlist 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
M DELETE EMAILS IN OUTLOOK 2010__ Using Outlook 2
I My "DELETE" key does not work when I am in my Outlook email but works when in other emails such as G Using Outlook 2
T unable to move or delete emails in IMAP folder Using Outlook 2
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
D after delete mail, open the next one Outlook VBA and Custom Forms 0
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
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
undercover_smother Automatically Forward All Sent Mail and Delete After Send Outlook VBA and Custom Forms 10
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
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
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

Similar threads

Top