So as to keep Outlook mailbox in small size and prevent Outlook data corruption, it is suggested to remove attachments from the emails which were received or sent a specific period ago. This article will help you quickly accomplish it with Outlook VBA.
As we all know, with Outlook mailbox larger, Outlook data will become much more vulnerable. Therefore, I get used to removing the attachments in the aged emails which are older than a specific date, since that I usually have saved these attachments to my local disk before. But it is a bit troublesome that I have to find out what emails are aged and then manually remove the attachments. In order to improve my efficiency, I come up with a solution by means of Outlook VBA.
Remove Attachments from Received Emails Older Than a Specific Date
- To begin with, open Outlook and turn to “Developer” tab.
- Then press the “Visual Basic” button in the “Code” group.
- A new window will turn up. In it, you should open a new module and copy the following codes into it.
Sub RemoveAttachmentsfromAgedEmail() Dim olInbox As Outlook.Folder Dim varItem As Variant Dim i As Integer Dim intDatDiff As Integer Dim Att As Attachment Set olInbox = Session.GetDefaultFolder(olFolderInbox) For i = olInbox.Items.Count To 1 Step -1 Set varItem = olInbox.Items.Item(i) If varItem.Class = olMail Then 'calculate the period between now and the received time intDatDiff = DateDiff("d", varItem.ReceivedTime, Now) 'You can replace "50" as per your needs If intDatDiff > 50 Then For Each Att In varItem.Attachments Att.Delete Next Att varItem.Save End If End If Next End Sub
- Now you can exit the current “Visual Basic” window and proceed to add the macro to Quick Access Toolbar. Follow the steps below:
- Firstly, hit the down arrow in the Quick Access Toolbar and choose “More Commands” from the drop down list.
- Then you should select “Macros” in “Choose commands from” field.
- Next select the correct macro and click “Add” button in center.
- Lastly, click “OK” button to enable it and back to Outlook main window.
- Eventually you can find and click on the button in Quick Access Toolbar. The attachments in the mails, which are older than your specified date, will get removed quickly.
Remove Attachments from Sent Emails Older Than a Specific Date
To achieve this aim, you can copy the whole VBA codes above but change some certain lines by following the notices below:
- Firstly, change all the “olInbox” to “olSentItemFolder” in the VBA codes.
- Then replace “Set olInbox = Session.GetDefaultFolder(olFolderInbox)” with:
Set olSentItemFolder = Session.GetDefaultFolder(olFolderSentMail)
- Next replace “intDatDiff = DateDiff(“d”, varItem.ReceivedTime, Now)” with:
intDatDiff = DateDiff("d", varItem.SentOn, Now)
Eliminate Annoying Outlook Errors
If you’ve used Outlook for a long time, frequent errors must have become common matters. It is apparent that you cannot predict or completely get rid of them. What you can do is just to try your best to resolve them. For example, use the inbox repair tool, Scanpest.exe to fix Outlook email error. Also, you have to make a regular backup for your Outlook data in case of unanticipated crash.
Author Introduction:
Shirley Zhang is a data recovery expert in DataNumen, Inc., which is the world leader in data recovery technologies, including repair SQL Server mdf damage and outlook repair software products. For more information visit www.datanumen.com
If you have any troubles, there is professional customer support available 24/7. You’ll never be laid off with problems. You’ll know the essential info concerning a woman before calling her. It would aid to recognize something regarding their background if you desire to date a person from Russia. Despite from which history or culture you originate from, you will certainly never ever be evaluated by Ukrainian. He is in love with Ukrainian culture, landscapes and also its stunning girls for the last 5 years. Does not matter if you are 20 or 60 years old, we can help you to locate an ideal partner. Cost-free ones typically aim to assist you in flirting or just making the initial steps. It also permits individuals to check out the very first messages they get absolutely free. CHECKED OUT COMPLETE EVALUATION: JollyRomance Evaluation: Is JollyRomance a Legit Dating Internet Site? You will need to get a credit score bundle to maximize your worldwide interaction experience. I can advise you to look via UaDreams complete info if you are still looking for a trusted dating agency without rip-offs. Internet innovation, detailed Uadreams fullinfo, lack Uadreams frauds, straightforward Uadreams login give clients with the choice of a companion, which appropriates for a major partnership!
The registration is simple and also does not take much time. So don’t hurry things as well as take it reduce. Remember once you have actually developed a link with a Russian female and also are considering marital relationship, things get complicated. Right here, 100 take a look at made from things you can do, and the benefits they are able to provide during the cooler months. Go with enchanting days and also take her out dancing. You can learn the price of all our solutions on our web site, the rates you will discover are exact as well as do n`t have any hidden charges. I obtain it. It can be a challenging choice to make when you’re simply starting out in the on the internet dating globe. There is absolutely nothing like that very first face-to-face conference in which you really reach see her and also provide her your very first hug. These websites provide you a perception that Russian ladies are determined to satisfy foreigners and sometimes can lead to a rather unfavorable impact concerning Russian females. We arrange Ukraine Matchmaking Tours – songs events, where males and females fulfill each other personally, where they may start the love which will lead to enjoy as well as marital relationship. At our introduction solution you will locate ladies personals with photos of straightforward and single Russian and also Ukrainian women seeking men and also spirit friends of any ages, for love, marriage and also love worldwide you will certainly also find some valuable details and short articles regarding Russian as well as Ukrainian bride-to-bes as well as important document recommendations.
Russian ladies in our company have currently prepared themselves before they chose to join our dating website to fulfill severe looking solitary men from around the world. The checklist pointed out over has just tried-and-true resources that whole lots of people all over the globe usage every day. This post contains a listing of the most frequently-visited and reliable websites with a concentrate on Ukrainian women. Our site contains not only details on our solutions, but will additionally assist you to recognize what Russia and also Ukraine are, their custom-mades and also traditions, explaining why Ukrainian women and also russian ladies are so different from the others. Ukrainian Real Brides web site has 6 personal matchmaking programs which will certainly assist you to develop delighted connections, household and also to fulfill your fiancée. Every one of these top qualities make Ukrainian women really preferable buddies! Honest females looking for households are not mail order goods you can order on the Web.
Search for a partner to develop a family members on the Net is progressively prominent, according to the stats of Google. We are below to serve you and also we will certainly assist you as long as we can on every phase of your search. Dream Singles will certainly assist you discover your dream single within secs as well as free of cost. There are many dating sites and also complimentary Russian women personals services offering you the most stunning, model-quality and also hot single girls but not all are what they appear. These websites do not most likely to the difficulty and also expenditure of finding and inspecting all the single females they publish. Some Russian dating firms (particularly complimentary dating sites) have obtained a poor track record from a few unethical and unprofessional procedures. Be aware of those songs complimentary dating sites supplying addresses totally free. If you beware concerning Russian as well as ukrainian females dating websites or have had negative luck with them in the past, we comprehend your mistrust. How to win the heart of a girl on this Ukrainian dating site? Each woman has an image in addition to her individual details, so please do not hesitate to search the website to have a concept of the kind of women you can fulfill and also let us aid you to discover that ideal life companion.
Thanks for your macro! It really helped me to get started, but I did find there was an issue when e-mail items have multiple attachments, presumably because the For Each loop breaks when you delete attachment items because I was able to fix it by using a regular For loop to iterate the attachment items.
I also needed to prevent it from iterating through all e-mail items for better performance in large mailboxes and have the liberty to run it on a folder of choice.
I hope this might help someone else down the road and the formatting comes out alright. Cheers!
Sub RemoveAttachmentsfromAgedEmail()
Dim olTargetFolder As Outlook.Folder
Dim colItems As Outlook.Items
Dim mailItem As Outlook.mailItem
Dim i, j As Integer
Dim intDatDiff As Integer
Dim ArchiveDate As String
Dim Filter As String
‘ let user pick folder
Set olTargetFolder = Application.GetNamespace(“MAPI”).Session.PickFolder()
‘ parse archivedate for one year ago
ArchiveDate = Format(DateAdd(“d”, -365, Now), “ddddd h:nn AMPM”)
‘ need to restrict items with filter to avoid iterating all, we only want those with attachments older than one year
Filter = “@SQL=” & Chr(34) & “urn:schemas:httpmail:hasattachment” & Chr(34) & “=1 AND ” & _
Chr(34) & “urn:schemas:httpmail:datereceived” & Chr(34) & “<='" & ArchiveDate & "'"
' apply the filter on the items in the choosen folder and take the rest
Set colItems = olTargetFolder.Items.Restrict(Filter)
For i = colItems.Count To 1 Step -1
Set mailItem = colItems.Item(i)
'Debug.Print ("Found: " & mailItem.Subject & "received: " & mailItem.ReceivedTime)
For j = mailItem.Attachments.Count To 1 Step -1
'Debug.Print ("Removed: " & Att.DisplayName)
mailItem.Attachments.Item(j).Delete
Next
mailItem.Save
Next
End Sub