5

Whenever sending an email, I would like a copy of that email to be saved in the local folder, together with all attachments.

I don't think this is possible with a custom rule in Outlook but perhaps it could be done with a VBA script?

I use Outlook and MS Exchange.

Martijn Pieters
  • 1,048,767
  • 296
  • 4,058
  • 3,343
Datageek
  • 25,977
  • 6
  • 66
  • 70

1 Answers1

11

Sure it can be done using the Application_ItemSend event procedure to call a custom procedure which will save your sent mails to a local folder.

This code goes in "ThisOutlookSession" module.

Private Sub Application_ItemSend(ByVal Item As Object, Cancel As Boolean)
    Call SaveACopy(Item)
End Sub

Sub SaveACopy(Item As Object)
    Const olMsg As Long = 3

    Dim m As MailItem
    Dim savePath As String

    If TypeName(Item) <> "MailItem" Then Exit Sub

    Set m = Item

    savePath = "c:\users\your_user_name\desktop\"  '## Modify as needed
    savePath = savePath & m.Subject & Format(Now(), "yyyy-mm-dd-hhNNss")
    savePath = savePath & ".msg"


    m.SaveAs savePath, olMsg


End Sub

You will need to ensure that the specified path is unique/etc., the above example is fairly crude. You also need strip out any illegal characters that can't be put in a file name (slash, pipes, etc.)...

As an alternative, I would suggest simply archiving your folder(s) periodically. You can configure Outlook to save a copy of sent mail to a "Sent" folder, and then you should be able to archive that folder; saving each item individually seems less-than-optimal.

David Zemens
  • 53,033
  • 11
  • 81
  • 130
  • 1
    Thanks David. Is there a way to automate the archiving of the folder? – Datageek Jul 30 '14 at 15:38
  • 3
    That sounds like a separate question... If this works for you, please consider accepting the answer. – David Zemens Jul 30 '14 at 15:48
  • how can I save the file and make the "file creation" date the same as the date that the email was received – software is fun Jun 01 '17 at 19:18
  • 1
    @softwareisfun See [this](http://www.cpearson.com/excel/FileTimes.htm) and ask a new, separate question please if you are stuck (instead of replying to comments on *this* answer to *this* question). Cheers. – David Zemens Jun 01 '17 at 20:14