PDA

View Full Version : deleting message after reply



zukzex
08-08-2012, 05:57 AM
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

JP2112
08-08-2012, 07:01 AM
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.


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

zukzex
08-08-2012, 08:40 AM
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.

zukzex
08-08-2012, 08:47 AM
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

zukzex
08-08-2012, 09:07 AM
Hi JP,

ok for the button. just the delete permanently. thanks

JP2112
08-13-2012, 05:36 AM
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/outlook-vba/delete-expired-items/