|
|
|
|
|
|
Outlook
|
Print and delete emails; check for attachments before deleting
|
|
Ease of Use
|
Easy
|
Version tested with
|
2003
|
Submitted by:
|
mdmackillop
|
Description:
|
Selected emails will be printed and deleted. If an email contains an attachment, the user will be asked to confirm deletion.
|
Discussion:
|
Do I need to explain further?
|
Code:
|
instructions for use
|
Option Explicit
Public Sub PrintDelete()
Dim objOL As Outlook.Application
Dim objMsg As Outlook.MailItem
Dim objAttachments As Outlook.Attachments
Dim objSelection As Outlook.Selection
Dim i As Long
Dim lngCount As Long
Dim Response As Integer
Dim msg As String
Dim strSubject As String
Set objOL = CreateObject("Outlook.Application")
Set objSelection = objOL.ActiveExplorer.Selection
For i = objSelection.Count To 1 Step -1
lngCount = objSelection(i).Attachments.Count
If lngCount > 0 Then
strSubject = objSelection(i).Subject
If strSubject = "" Then
msg = "Selected item #" & i
Else
msg = strSubject
End If
Response = MsgBox(msg & " has attachments." & vbCr _
& "Do you wish to delete?", vbYesNo)
If Response = vbNo Then
objSelection(i).PrintOut
Else
objSelection(i).PrintOut
objSelection(i).Delete
End If
Else
objSelection(i).PrintOut
objSelection(i).Delete
End If
Next
ExitSub:
Set objAttachments = Nothing
Set objMsg = Nothing
Set objSelection = Nothing
Set objOL = Nothing
End Sub
|
How to use:
|
- Paste the code in a Standard Module within Outlook
- Assign a Button or Keyboard Shortcut to the macro.
|
Test the code:
|
- Select one or more dispensable emails, some of which contain attachments.
- Emails with no attachments will be printed and deleted.
- If an email contains an attachment, the prompt, containing the Subject (if any) or the Index (if none) will ask for confirmation.
- Select No to print but not delete.
-
- Save money by printing to a PDF printer!
|
Sample File:
|
No Attachment
|
Approved by lucas
|
This entry has been viewed 114 times.
|
|