Developing Matt

My Technical Journal

Send without save (outlook)

with one comment

I don’t like the outlook send mail box.  I forget it’s there, it sits on the server and collects and fills up my outlook profile.  Quite honestly, 75% of the emails I send out I don’t want to keep.  They are a waste of space.  So when I send an email out I’d like the option to not keep it, is that too much to ask?  So I set out to create a macro that sends mail but doesn’t save it in the sent items folder.   Outlook vba isn’t easy, at least not for me.  The objects on top of objects on top of objects leave me confused sometimes, and the active inspector concept has to be utilized, but I wasn’t quite sure how.   So I had a little help from the koder’s search engine: link (ok, ok, all of this code comes from that link).  Anyway, here is a vba script that will send your message but not save it in the sent folder.  You’ll only want to call this from an active mail window (I set a custom button to the the macro). 

Public Sub SendWithoutSave()
    ‘perform the send
    Dim oInsp As Outlook.Inspector
    Dim oMail As Outlook.mailitem
    Dim oCntr As Object
    Dim bNoMailItem As Boolean
    ‘make sure the function is invoked from
    ‘     a mail item
    If TypeName(Application.ActiveWindow) = “Inspector” Then
        ‘There is an inspector!
        Set oInsp = Application.ActiveInspector
        ‘Is it really a mail item?
        If TypeName(oInsp.CurrentItem) <> “MailItem” Then
            bNoMailItem = True
        End If
        bNoMailItem = True
    End If
    If bNoMailItem Then
        MsgBox “This Function must be invoked from within a mail item”
        Exit Sub
    End If
    Set oMail = oInsp.CurrentItem
    ‘prevent from save
‘    oMail.SaveSentMessageFolder = False  (this is the old way in outlook 2000)
    oMail.DeleteAfterSubmit = True
    ‘Send it
End Sub

Also, so you know…if you think this will keep your emails from being caught by IT, then let me recommend that you keep work email clean and appropriate.  This is not your great escape from HR pergatory and will not keep you ‘safe’ with regards to your risky outlook messages.


Written by matt

August 28, 2007 at 1:36 pm

Posted in VBA

One Response

Subscribe to comments with RSS.

  1. for outlook 2007 just comment out the following
    ‘ If TypeName(oInsp.CurrentItem) “MailItem” Then
    ‘ bNoMailItem = True
    ‘ End If
    as the first line returns the subject not the object name.


    February 7, 2008 at 7:41 am

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: