Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to clear outbox in outlook automatically after Send

Status
Not open for further replies.

GaryTYY

Programmer
Jan 23, 2015
4
CZ
I simply want to perform a "send" of a message to specific recipient but dont want to deliver, its all ok the message is in outbox but I want to delete it immediatelly from the outbox but when I use the command delete it says it was deleted before sending. If I use cancel then it will not perform the send. I don't want popups and also there is an alert when exiting outlook that there are still unsend messages.. So how to clear outbox?

I even delayed message so it will never deliver but it is stucked in outbox and I want to remove it.
Thank you!
Code:
Public Sub Application_Startup()

End Sub
Private Sub Application_ItemSend(ByVal item As Object, Cancel As Boolean)

Dim outApp As Outlook.Application
Dim deletedFolder As Outlook.MAPIFolder

Dim entryID As String

Set outApp = CreateObject("outlook.application")
Set deletedFolder  =outApp.GetNamespace("MAPI").GetDefaultFolder(olFolderOutbox)

 If item.To = "example@mail.com" Then
 item.DeferredDeliveryTime = DateAdd("y", 99999, Now)
 End If

 Set deletedFolder =    outApp.GetNamespace("MAPI").GetDefaultFolder(olFolderOutbox)


If deletedFolder.Items.Count >= 0 Then
For i = 1 To deletedFolder.Items.Count
deletedFolder.Items(1).Delete
Next i
End If

End Sub
 
You do understand that the Outbox is the place where e-mails are temporary stored before they are sent. Once the Send/Receive process occurs (normally set up to do it automatically every X minutes or at start-up/shutdown of Outlook), messages are automatically moved from the Outbox folder to the Sent Items folder.

If you delete a message in the Outbox, it will not be sent.

What I think you are wanting to do is to set up Outlook to automatically send items from your Outbox. Under File, Options, Advanced there's an item Send and receive with a box and a Send/Receive button. Check the box, and click the button to set up at what time interval you want Outlook to automatically send/receive messages.
 
no I really do want to delete that message before send.. seriously I want and I understand it normally. I do not want to send it. Any idea how to do that?
 
That's like saying, "I want to dry off before I enter the shower."

What is the REASON for this very unusual requirement???
 
In case our employees send a message to the wrong person.
 
On a local level, I see more nefarious reasons for wanting this than legitimate ones (e.g., someone wanting to stop X from emailing the boss or the bosses boss about something, or wanting to stop X from emailing someone outside of the agency.) The only legitimate reason I've experienced of why you'd want this to happen is to stop people from doing a Reply All to an agency-wide email (and others doing a Reply All to that email as well). To prevent things like that (i.e., Reply All to an agency-wide email), I think was done at the mail server point, and not at a local level.

GarTYY said:
In case our employees send a message to the wrong person.
Unfortunately, you can't always fight stupidity. If you want to try and create a Rule or Macro to automatically delete any emails that have User X in the To, CC, BCC, you may be able to; BUT there may be a legitimate reason for the email. Setting up things to automatically delete something is likely to cause more problems than the infrequent sending an email to the wrong person.

Also, remember if the user isn't sending any emails (i.e., if emails are being stored in the Outbox) then the user isn't receiving any emails as well. You're more likely creating more problems because the user isn't receiving their emails and delaying getting work done.
 
but the macro will be trigered only by specific emails
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top