Delete old emails

Status
Not open for further replies.

Julian_TotalAssist

New Member
Outlook version
Outlook 2013 32 bit
Email Account
Exchange Server 2010
Hello,

Trying to resolve a problem with deleting 30 old specific emails.
Emails are located in outlook folder and trying to extract Message-ID for each email (as it's unique) export it. And then use that info and run powershell command to delete that email.

Looking for options how to extract only Message-Id(email header) from outlook folder and save it to a file?

Any ideas guys?

Thanks

Julian
 

Diane Poremsky

Senior Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Are you only deleting some of the messages in the folder?

Message_id is PR_INTERNET_MESSAGE_ID - how to get it sample is here - Read MAPI properties not exposed in Outlook's Object Model

The entry id is objectname .EntryID

This shows show to get the full header and write it to a file (in the form of a new message) using VBA - Get Outlook's Internet Headers using VBA

writing to a text file is fairly simple:

Dim objFS As New Scripting.FileSystemObject, objFile As Scripting.TextStream
StrFile = "C:\folder\" & sName & ".txt"
Set objFile = objFS.CreateTextFile(StrFile, False)
If objFile Is Nothing Then
MsgBox "Error creating file '" & StrFile & "'.", vbOKOnly + vbExclamation _
, "Invalid File"
Exit Sub
End If

With objFile
.Write "<a href='" & strURL & "'><strong>" & strSubject & "</strong></a> <br />" & vbCrLf
.Write strBody & "<br /><br />" & vbCrLf & vbCrLf
End With

objFile.Close

the With objfile block should be inside the loop that gets the message id:
'get new message
'code to get message ld
'write it to file
'loop to next new message
 
Status
Not open for further replies.
Thread starter Similar threads Forum Replies Date
B Delete/replace old files and save new attachments Using Outlook 1
Rupert Dragwater How to delete old rules and create new in Outlook 2013 Using Outlook 12
C Organize contacts and get rid of old ones that continue to show up every time I delete them. Using Outlook 1
J To delete the draft 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 14
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
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
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
makinmyway Bulk Delete Contacts in iOS Outlook App Using Outlook 4
Diane Poremsky Delete an Outlook Group New Slipstick.com Articles 0
M Cannot Delete Emails from IMAP inbox Using Outlook 4
K Deleted calendar and contact items not going to delete folder Using Outlook 1
K Outlook 2013 Deleted calendar and contact items not going to delete folder Exchange Server Administration 1
J Adding Reply & Delete to main toolbar? Using Outlook 0
Reji Rajan Delete Data Outlook VBA and Custom Forms 1
K check for sender, follow to my personal adress and delete the sent folder. Outlook VBA and Custom Forms 1
Similar threads


















































Top