Outlook 2010 Automatically Forward All Sent Mail and Delete After Send

Outlook version
Outlook 2016 64 bit
Email Account
Exchange Server
#1
Greetings,

I've tried a few options but none have worked. I'm trying to get all SENT emails from a 2010 email account to forward to another email account (on same server; I don't know if that is relevant) and to delete the forwarded email.

Some notes:
- This is to observe an employee that I oversee for suspected nefarious behavior (not ready to have franchise IT get involved yet...for many reasons)
- Attachment contents aren't relevant; attachment title is kind of relevant, but not mandatory
- Needs to be triggered by either a rule (less-ideal), or some kind of a listener in VBA (more ideal) - I don't want this person to see a rule with a script name in it

I've tried the code (from this site) below but it was not working:

Sub ChangeSubjectForward(Item As Outlook.MailItem)

Set myForward = Item.Forward
myForward.Recipients.Add "alias@domain.com"

' To BCC an address or DL, try this:
'myForward.BCC = "alias"

myForward.DeleteAfterSubmit = True

myForward.Send

End Sub
Perhaps it's just me doing something wrong. Anyone have any ideas?

Thanks in advance for the help.
 
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#3
Editing should work for about 10 min... I will double check the settings.

An itemsend macro would be best if you are doing it client side, but all they need to do is look in the VBA editor... they could also disable it by restarting outlook in safe mode. Automatically BCC All Messages Oh, and they'll see the BCC if they look in sent mail.

A better option would be the admin giving you mailbox rights - I'll have to double check, but i don't think he'd see it in permissions. Exchange also has the capability to forward mail sent to and from mailboxes (journaling or mail flow rules) - this would also be totally hidden from the user. Either is much better than using a macro - and totally secretive. But only the Exchange admin can set it up.

I would use mail flow, as mailbox rights would open the mailbox in your profile and you run the risk of marking mail read and tipping him off. Journaling is kind of a pita as messages are forwarded to the journal mailbox as attachments.

Monitoring Employees Email
 
Outlook version
Outlook 2016 64 bit
Email Account
Exchange Server
#4
Editing should work for about 10 min... I will double check the settings.

An itemsend macro would be best if you are doing it client side, but all they need to do is look in the VBA editor... they could also disable it by restarting outlook in safe mode. Automatically BCC All Messages Oh, and they'll see the BCC if they look in sent mail.

A better option would be the admin giving you mailbox rights - I'll have to double check, but i don't think he'd see it in permissions. Exchange also has the capability to forward mail sent to and from mailboxes (journaling or mail flow rules) - this would also be totally hidden from the user. Either is much better than using a macro - and totally secretive. But only the Exchange admin can set it up.

I would use mail flow, as mailbox rights would open the mailbox in your profile and you run the risk of marking mail read and tipping him off. Journaling is kind of a pita as messages are forwarded to the journal mailbox as attachments.

Monitoring Employees Email
Thank you for that - unfortunately Journaling or mail flow would require involving franchise IT while would open up issues that I don't want to have to answer to...until I can prove that what I think is happening, is happening.

The employee doesn't know anything about VBA so they'd never look in the editor. I can already use rules to automatically CC all sent messages to myself, so I guess I need to be able to just delete those messages after they are sent. When you use rules, the person doesn't see the CC unless they look in the sent folder.

Maybe a better question would be to ask how to automatically delete (perm) messages that are forwards from him to me? I tried setting up a rule that was like //FROM:employee//TO:me// but that didn't automatically trigger. It seemed like it was on a delay. the deletion rule did work if I manually told the rule to run, however.

Any thoughts? Thanks for help!
 
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#5
You only need sent items? It might work to watch the sent folder and send as attachment, then delete the forward. This way you won't have the forward icon or the sent item.

Test this, forwarding messages you send to yourself. it goes in thisoutlooksession - then restart outlook.
Code:
Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
  Dim Ns As Outlook.NameSpace
  Set Ns = Application.GetNamespace("MAPI")
  Set Items = Ns.GetDefaultFolder(olFolderSentMail).Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
  On Error Resume Next

  Dim objMsg As MailItem
  Set objMsg = Application.CreateItem(olMailItem)

   objMsg.To = "you@domain.com"
   objMsg.Subject = Item.Subject
   objMsg.Attachments.Add Item
      objMsg.DeleteAfterSubmit = True
objMsg.Send
   
   Set objMsg = Nothing

End Sub
 
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#6
BTW, you could do it for inbox too..
Add these lines after the similar originals:
Private WithEvents InboxItems As Outlook.Items
Set InboxItems = Ns.GetDefaultFolder(olFolderinbox).Items

Then duplicate the items_itemadd macro, renaming the copy Private Sub InboxItems_ItemAdd(ByVal Item As Object)

or create stubs and share the main macro:

Code:
Private WithEvents Items As Outlook.Items
Private WithEvents InboxItems As Outlook.Items

Private Sub Application_Startup()
  Dim Ns As Outlook.NameSpace
  Set Ns = Application.GetNamespace("MAPI")
  Set Items = Ns.GetDefaultFolder(olFolderSentMail).Items
  Set InboxItems = Ns.GetDefaultFolder(olFolderInbox).Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
ForwardMessage Item
End Sub

Private Sub inboxItems_ItemAdd(ByVal Item As Object)
ForwardMessage Item
End Sub

Private Sub ForwardMessage(ByVal Item As Object)
  On Error Resume Next
  Dim objMsg As MailItem
  Set objMsg = Application.CreateItem(olMailItem)

   objMsg.To = "you@domain.com"
   objMsg.Subject = Item.Subject
   objMsg.Attachments.Add Item
      objMsg.DeleteAfterSubmit = True
objMsg.Send
   
   Set objMsg = Nothing

End Sub
 
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#7
actually, that is not working well for inbox items - they are marked read.

use this as the inbox stub:
Private Sub inboxItems_ItemAdd(ByVal Item As Object)
ForwardMessage Item
Item.UnRead = True
'Item.Save
End Sub
 
Outlook version
Outlook 2016 64 bit
Email Account
Exchange Server
#8
You only need sent items? It might work to watch the sent folder and send as attachment, then delete the forward. This way you won't have the forward icon or the sent item.

Test this, forwarding messages you send to yourself. it goes in thisoutlooksession - then restart outlook.
Code:
Private WithEvents Items As Outlook.Items

Private Sub Application_Startup()
  Dim Ns As Outlook.NameSpace
  Set Ns = Application.GetNamespace("MAPI")
  Set Items = Ns.GetDefaultFolder(olFolderSentMail).Items
End Sub

Private Sub Items_ItemAdd(ByVal Item As Object)
  On Error Resume Next

  Dim objMsg As MailItem
  Set objMsg = Application.CreateItem(olMailItem)

   objMsg.To = "you@domain.com"
   objMsg.Subject = Item.Subject
   objMsg.Attachments.Add Item
      objMsg.DeleteAfterSubmit = True
objMsg.Send
  
   Set objMsg = Nothing

End Sub
Thank you for this. I've tried this on my own system and it didn't seem to forward the mail.

That being said, I have Outlook 2016 and I need this for a computer running Outlook 2010 - I don't know if that makes a difference. I'm by no means a VBA pro but I don't see where the second sub above looks in the sent folder. The first names "Items" as the default sent mail folder but I don't see where it is called in the second sub. Am I missing something?
 
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
#9
it will work in 2007 and up.
These lines tell it where to watch:
Set Items = Ns.GetDefaultFolder(olFolderSentMail).Items
Set InboxItems = Ns.GetDefaultFolder(olFolderInbox).Items

the entire set of code needs to be in thisoutlooksession, you need macro security set to low and you need to restart outlook.

How to use Outlook's VBA Editor
Processing Incoming E-mails with Macros
 
Outlook version
Outlook 2016 64 bit
Email Account
Exchange Server
#10
Top