🔒 Closed Delete the attachment in sent emails

Status
Not open for further replies.

Stenning

Leecher
hi,

I always need to send files in emails in outlook. And the attachment seems the biggest one to increase my pst file size.

I can delete the emails after sending them, but I need to keep the text information in the email. So I hope I can only delete the attachments in the sent emails without deleting the whole emails. Is that possible? Thanks
 
For a quick way, you can use VBA. I just find one macro, you can try

Code:
Public WithEvents objSentMails As Outlook.Items

Private Sub Application_Startup()
    Set objSentMails = Outlook.Application.Session.GetDefaultFolder(olFolderSentMail).Items
End Sub

Private Sub objSentMails_ItemAdd(ByVal Item As Object)
    Dim objSentMail As Outlook.MailItem
    Dim objAttachments As Outlook.attachments
    Dim i As Long
    Dim strAttachmentInfo As String
 
    'Only work on emails
    If Item.Class = olMail Then
       Set objSentMail = Item
    End If
 
    Set objAttachments = objSentMail.attachments
 
    While objAttachments.Count > 0
          'Get the information of removed attachments
          strAttachmentInfo = "<HTML><BODY>Attachment Removed: " & objAttachments.Item(1).DisplayName & "</HTML></BODY>---------------------------------------------------------" & strAttachmentInfo
          objAttachments.Item(1).Delete
    Wend
 
    'Insert the information of removed attachments to the body
    objSentMail.HTMLBody = strAttachmentInfo & objSentMail.HTMLBody
    objSentMail.Save
End Sub

And here are the article with the detailed steps. You may need this:

You do not have permission to view the full content of this post. Log in or register now.

Good luck
 
Status
Not open for further replies.

About this Thread

  • 3
    Replies
  • 185
    Views
  • 3
    Participants
Last reply from:
Natiel

Trending Topics

Online now

Members online
1,146
Guests online
1,078
Total visitors
2,224

Forum statistics

Threads
2,274,535
Posts
28,956,637
Members
1,234,271
Latest member
rararahe
Back
Top