Note that there are some explanatory texts on larger screens.

plurals
  1. POHow do I make Outlook purge a folder automatically when anything arrives in it?
    primarykey
    data
    text
    <p>I hope it's okay to ask this kind of question. Attempting to write the code myself is completely beyond me at the moment.</p> <p>I need a macro for Outlook 2007 that will permanently delete all content of the Sent Items folder whenever anything arrives in it. Is it possible? How do I set everything up so that the user doesn't ever have to click anything to run it?</p> <p>I know I'm asking for a fish, and I'm embarrassed, but I really need the thing... </p> <p><strong>edit:</strong></p> <p>I've pasted this into the VBA editor, into a new module:</p> <pre><code>Public Sub EmptySentEmailFolder() Dim outApp As Outlook.Application Dim sentFolder As Outlook.MAPIFolder Dim item As Object Dim entryID As String Set outApp = CreateObject("outlook.application") Set sentFolder = outApp.GetNamespace("MAPI").GetDefaultFolder(olFolderSentMail) For i = sentFolder.Items.Count To 1 Step -1 sentFolder.Items(i).Delete '' Delete from mail folder Next Set item = Nothing Set sentFolder = Nothing Set outApp = Nothing End Sub </code></pre> <p>It's just a slightly modified version of a piece of code I found somewhere on this site deleting Deleted Items. It does delete the Sent Items folder when I run it. Could you please help me modify it in such a way that it deletes Sent Items whenever anything appears in the folder, and in such a way that the user doesn't have to click anything to run it? I need it to be a completely automated process.</p> <p><strong>edit 2:</strong> Please if you think there's a better tool to achieve this than VBA, don't hesitate to edit the tags and comment.</p> <p><strong>edit 3:</strong> I did something that works sometimes, but sometimes it doesn't. And it's ridiculously complicated. I set a rule that ccs every sent email with an attachment to me. Another rule runs the following code, when an email from me arrives.</p> <pre><code>Sub Del(item As Outlook.MailItem) Call EmptySentEmailFolder End Sub </code></pre> <p>The thing has three behaviors, and I haven't been able to determine what triggers which behavior. Sometimes the thing does purge the Sent Items folder. Sometimes it does nothing. Sometimes the second rule gives the "operation failed" error message. </p> <p>The idea of acting whenever something comes from my address is non-optimal for reasons that I'll omit for the sake of brevity. I tried to replace it with reports. I made a rule that sends a delivery report whenever I send an email. Then another rule runs the code upon receipt of the report. However, this has just one behavior: it never does anything.</p> <p>Both ideas are so complicated that anything could go wrong really, and I'm having trouble debugging them. Both are non-optimal solutions too.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload