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!
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