Consulting

Results 1 to 6 of 6

Thread: deleting message after reply

  1. #1
    VBAX Newbie
    Joined
    Aug 2012
    Posts
    4
    Location

    deleting message after reply

    hello all,
    i am wanting to write a vba for outlook 2010 where the vba will delete a message from a specific sender after i replied to the mail and also delete the reply in the sent folder.

    this is my first time dealing with outlook vba though i am quick ok with excel vba.

    any help would be much appreciated. thanks

  2. #2
    VBAX Expert JP2112's Avatar
    Joined
    Oct 2008
    Location
    Astoria, NY
    Posts
    590
    Location
    I feel obligated to discourage you from doing this. If there is ever a dispute about the content of the message, you'll have no record of what you wrote.

    Assign this code to a toolbar button (QAT) and click it when you want to reply to a message and delete both the original and the reply.

    [VBA]
    Sub ReplyAndDelete()
    Dim msg As Outlook.mailItem
    Dim replyMsg As Outlook.mailItem
    ' assume currently selected item is an email you want to reply to
    Set msg = ActiveExplorer.Selection.Item(1)
    Set replyMsg = msg.Reply
    With replyMsg
    .Display
    ' put reply into Deleted Items folder (instead of Sent Items)
    Set .SaveSentMessageFolder = session.GetDefaultFolder(olFolderDeletedItems)
    End With
    ' delete original message
    msg.Delete
    End Sub
    [/VBA]
    Regards,
    JP

    Read the FAQ
    Getting free help on the web
    My website
    Please use [vba][/vba] tags when posting code

  3. #3
    VBAX Newbie
    Joined
    Aug 2012
    Posts
    4
    Location
    thanks JP. will try this and let u know if its ok.
    P.S. dont worry about the content of the mail. there will never be any dispute.

  4. #4
    VBAX Newbie
    Joined
    Aug 2012
    Posts
    4
    Location
    hello JP,

    thats awesome, i just have 2 more questions.

    how do i create a button to assign the macro. and how to delete the mail and sent mail permanently.

    thanks

  5. #5
    VBAX Newbie
    Joined
    Aug 2012
    Posts
    4
    Location
    Hi JP,

    ok for the button. just the delete permanently. thanks

  6. #6
    VBAX Expert JP2112's Avatar
    Joined
    Oct 2008
    Location
    Astoria, NY
    Posts
    590
    Location
    To assign the code to a button on the QAT, see http://www.howto-outlook.com/howto/macrobutton.htm.

    To empty the Deleted Items folder, see http://www.jpsoftwaretech.com/outloo...expired-items/
    Regards,
    JP

    Read the FAQ
    Getting free help on the web
    My website
    Please use [vba][/vba] tags when posting code

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •