Delete All Attachments on Sent Items


 

I received that tweet a few days ago. Here’s the solution I put together for Rick.

Requirements.

This solution should work in all versions of Outlook from 2003 on.

Instructions.

Follow these instructions to add the code to Outlook.

  1. If not already expanded, expand Microsoft Office Outlook Objects and click on ThisOutlookSession
  2. Copy the code from the code snippet box and paste it into the right-hand pane of Outlook’s VB Editor window
  3. Click the diskette icon on the toolbar to save the changes
  4. Close the VB Editor
  5. Click File and select Options
  6. When the Outlook Options dialog appears click Trust Center then click the Trust Center Settings button
  7. Click Macro Settings
  8. Select either of the two bottom settings (i.e. Notifications for all macros or Enable all macros (not recommended; potentially dangerous code can run). The choice of which to choose is up to you. If you select Notifications, then you’ll be prompted at times to enable macros. If you pick Enable all then there’s a chance that a malicious macro could run. It’s a question of how much risk you want to assume.
  9. Click Ok until the dialog-boxes have all closed
  10. Close Outlook
  11. Start Outlook. Outlook will display a dialog-box warning that ThisOutlookSession contains macros and asking if you want to allow them to run. Say yes.
Dim WithEvents olkSnt As Outlook.Items

Private Sub Application_Quit()
    Set objSnt = Nothing
End Sub

Private Sub Application_Startup()
    Set objSnt = Session.GetDefaultFolder(olFolderSentMail)
End Sub

Private Sub olkSnt_ItemAdd(ByVal Item As Object)
    Dim olkAtt As Outlook.Attachment, lngCnt As Long
    For lngCnt = Item.Attachments.count To 1 Step -1
        Set olkAtt = Item.Attachments(lngCnt)
        If Not IsHiddenAttachment(olkAtt) Then
            olkAtt.Delete
        End If
    Next
    Item.Save
    Set olkAtt = Nothing
End Sub

Private Function IsHiddenAttachment(olkAtt As Outlook.Attachment) As Boolean
    Const PR_ATTACH_CONTENT_ID = "http://schemas.microsoft.com/mapi/proptag/0x3712001E"
    Dim olkPA As Outlook.PropertyAccessor, varTemp As Variant
    On Error Resume Next
    Set olkPA = olkAtt.PropertyAccessor
    varTemp = olkPA.GetProperty(PR_ATTACH_CONTENT_ID)
    IsHiddenAttachment = (varTemp <> "")
    On Error GoTo 0
    Set olkPA = Nothing
End Function

Reply All to Multiple Messages


 

A reader named Savio requested a solution enabling him to “reply all” to multiple messages at once. Here is that solution.

Sub ReplyAllToAllSelected()
    Dim olkMsg As Object, olkRpl As Outlook.MailItem
    For Each olkMsg In Application.ActiveExplorer.Selection
        If olkMsg.Class = olMail Then
            Set olkRpl = olkMsg.ReplyAll
            olkRpl.Display
        End If
    Next
    Set olkMsg = Nothing
    Set olkRpl = Nothing
End Sub

Requirements.

This solution should work in all versions of Outlook from 2003 on.

Instructions.

Follow these instructions to add the code to Outlook.

  1. Start Outlook
  2. Press ALT + F11 to open the Visual Basic Editor
  3. If not already expanded, expand Microsoft Office Outlook Objects
  4. If not already expanded, expand Modules
  5. Select an existing module (e.g. Module1) by double-clicking on it or create a new module by right-clicking Modules and selecting InsertModule.
  6. Copy the code from the code snippet box and paste it into the right-hand pane of Outlook’s VB Editor window
  7. Click the diskette icon on the toolbar to save the changes
  8. Close the VB Editor

Using the Solution.

Select one or more messages then run the ReplyAllToAllSelected macro. The macro will create a reply to each selected message and display it on screen. You can then add your reply and send the message.

Adding Buttons to Run the Macro with a Single Click.

If Savio wants to run the macro with a single click, then he’ll need to add a toolbar button in Outlook 2007 or a button on the Quick Access Toolbar (QAT) for Outlook 2010. Here’s how.

  • Outlook 2007. Follow these instructions to add a toolbar button that runs the macro.
  • Outlook 2010 – 2016. Follow these instructions to add the macro to the QAT.

Forward Messages at Certain Times of the Day


 

Today, while checking questions on Experts-Exchange, I stumbled across one where the author is looking for a way to forward messages during certain times of the day. S/he had found a potential solution on another blog, but was unable to get it to work. I had a look at that solution, and while it’s both clever and functional, I think there’s a simpler way to go about this and that’s to use a macro.
Continue reading