Attachments.Delete

adambc

New Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
I have the following VBA code working perfectly apart from the Att.Delete!

In summary, I want to save incoming mail attachments* to a folder* then delete the attachment from the incoming mail - Att.SaveAsFile works perfectly, but Att.Delete doesn't do anything! - any ideas please? ...

* as defined in the code

Public WithEvents olItems As Outlook.Items

Private Sub Application_NewMail()

End Sub

Private Sub Application_Startup()

Set olItems = Session.GetDefaultFolder(olFolderInbox).Items

End Sub

Private Sub olItems_ItemAdd(ByVal Item As Object)

Dim NewMail As Outlook.MailItem
Dim Atts As Attachments
Dim Att As Attachment
Dim strPath As String
Dim strName As String

If Item.Class = olMail Then
Set NewMail = Item
End If

Set Atts = Item.Attachments

If Atts.Count > 0 Then
For Each Att In Atts
If InStr(1, Att.FileName, "NEWINCIDENT", vbTextCompare) > 0 Then
strPath = "C:\Users\User\Documents\$$$ADAM\New_Incidents_Submitted\"
strName = Att.FileName
Att.SaveAsFile strPath & strName
Att.Delete
End If
Next
End If
End Sub
 

adambc

New Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Ah, silly me, thanks!!!

Isn't the following using the snippet you've highlighted?

Set Atts = Item.Attachments
 

adambc

New Member
Outlook version
Outlook 2016 32 bit
Email Account
Office 365 Exchange
Ah, silly me, thanks!!!

Isn't the following using the snippet you've highlighted?

Set Atts = Item.Attachments
ERRATUM ... you're quite right of course, I'm NOT using the snippet (and has now deleted it as redundant!!!

Many, many thanks again
 
Thread starter Similar threads Forum Replies Date
B Delete/replace old files and save new attachments Using Outlook 1
Jennifer Murphy How to delete attachments? Using Outlook 4
L Macro/VBA to Reply All, with the original attachments Outlook VBA and Custom Forms 2
M Deleting attachments does not reduce file size Using Outlook 0
L unblocking attachments before sending Office 365 Advanced Protection Using Outlook 0
I Saving attachments from multiple emails and updating file name Outlook VBA and Custom Forms 0
R Use an ItemAdd to Save Attachments on Arrival Outlook VBA and Custom Forms 0
shrydvd vba to secure zip attachments Outlook VBA and Custom Forms 3
R fetching blocked attachments Outlook VBA and Custom Forms 0
H Outlook 2016 sent over 30 copies of an e-mail with attachments Using Outlook 1
W Automatically open attachments without automatically printing them Using Outlook 0
O Save attachments using hotkey without changing attributes Outlook VBA and Custom Forms 1
T Outlook converts sent email to txt attachments when sync Using Outlook 0
Nadine Rule to move attachments with specific name Outlook VBA and Custom Forms 1
R Outlook is NOT removing attachments. Using Outlook 4
Dan_W Nested email attachments Outlook VBA and Custom Forms 4
M Print email and, attachments sent in hyperlinks in the email Outlook VBA and Custom Forms 2
W Save and rename outlook email attachments to include domain name & date received Outlook VBA and Custom Forms 4
S DRAGGING MAIL AND ATTACHMENTS TO CALENDAR Using Outlook 1
D Print attachments automatically and moves the mail to a new folder Outlook VBA and Custom Forms 9
G Download pdf attachments only if email subject has one of words Outlook VBA and Custom Forms 8
D Saving Selected Emails as PDF and saving Attachments Outlook VBA and Custom Forms 6
R Quick Access view in File Explorer when saving attachments Using Outlook 0
J Save E-mail attachments in a specific folder Outlook VBA and Custom Forms 0
O Wishlist Native solution to detach attachments but keep a link to them Outlook Wishlist 1
broadbander Needing help with reply/reply all while keeping attachments and adding a new CC recipient. Outlook VBA and Custom Forms 5
I Forwarding attachments in email received Outlook VBA and Custom Forms 3
A Outlook - Send New 20 Attachments through Email Using Outlook 4
D Print Attachments only in selected emails using a macro Outlook VBA and Custom Forms 3
M Outlook 2016 msg attachments Using Outlook 0
N Saving And Deleting Outlook Attachments with Unknown Error Message Outlook VBA and Custom Forms 1
M Macro for attachments download adjustment Outlook VBA and Custom Forms 3
M VBA macro for Inbox's attachments search Outlook VBA and Custom Forms 0
C Auto save outlook attachments when email is received Outlook VBA and Custom Forms 1
S Outlook 2010 Cannot Open Attachments Using Outlook 14
I Print Automatically Attachments Outlook VBA and Custom Forms 3
Diane Poremsky Save Messages and Attachments to a New Folder New Slipstick.com Articles 0
J Saving attachments from specific sender (phone number) to specific folder on hard drive Using Outlook 3
Diane Poremsky Disable Protected View for Outlook Attachments New Slipstick.com Articles 0
C Saving Outlook attachments and links to attachments with VBA Outlook VBA and Custom Forms 2
Diane Poremsky Remove Attachments From Messages New Slipstick.com Articles 0
Diane Poremsky Outlook is sending winmail.dat attachments New Slipstick.com Articles 0
Diane Poremsky Edit and Save Outlook's Read-Only Attachments New Slipstick.com Articles 0
J Forward Message after editing attachments and include edited attachments Using Outlook 5
Diane Poremsky Save Attachments to the Hard Drive New Slipstick.com Articles 2
A Add attachments to appointment based on field values Outlook VBA and Custom Forms 0
C Rule To Save attachments on receipt of email Outlook VBA and Custom Forms 2
Diane Poremsky Add Attachments and Set Email Fields During a Mail Merge New Slipstick.com Articles 0
S Autosave attachments error using Len Outlook VBA and Custom Forms 2
B Insert Hyperlinks for attachments in Userform Outlook VBA and Custom Forms 5
Similar threads


















































Top