-
Automatically save attachments when mail received ...
I know there are posts on this (and other) forum of a similar nature, but having tried countless of the answers, I cannot get any to work ...
I want to save attachments that I KNOW will be named NEWINCIDENT??????.xlsm (where ?????? is a unique string) to a named folder ...
I'm running Office 365 Home/Outlook Version 2002 (Build 12527.20278 Click-to-Run) ...
This is "typical" of the VBA code I've put into ThisOutlookSession ...
Public WithEvents olItems As Outlook.Items
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
'neither of the following 2 lines work
If Att.FileName = "NEWINCIDENT*.*" Then
'If InStr(LCase(Att.FileName), "NEWINCIDENT") > 0 Then
strPath = "C:\Users\User\Documents\$$$ADAM\New_Incidents_Submitted"
strName = NewMail.Subject & " " & Chr(45) & " " & Att.FileName
Att.SaveAsFile strPath & strName
End If
Next
End If
End Sub
... and Saved/restarted Outlook ...
... but it doesn't seem to do anything (at least not what I want it to!) ...
Can anyone help please?
Many thanks ...
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules