-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathCVG_Files.bas
29 lines (27 loc) · 870 Bytes
/
CVG_Files.bas
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
Attribute VB_Name = "CVG_Files"
Public Sub StoreDailySheetsAttachments(item As MailItem)
StoreAttachments item, "S:\ENERGY\Convergence\Daily_sheets"
End Sub
Public Sub StoreAttachments(item As MailItem, FolderName As String)
Dim i As Integer
Dim att As Attachment
Dim filepath As String
Dim save As Boolean
Dim fs As New FileSystemObject
For i = 1 To item.Attachments.Count
Set att = item.Attachments.item(i)
filepath = FolderName & "\" & Format(item.SentOn, "yyyymmdd") & "_" & att.FileName
If fs.FileExists(filepath) Then
Select Case MsgBox("Overwrite " & filepath & ", saved on " & FileDateTime(filepath) & " with new attachment?", vbYesNoCancel)
Case vbYes: save = True
Case vbNo: save = False
Case vbCancel: Exit Sub
End Select
Else
save = True
End If
If save Then
att.SaveAsFile filepath
End If
Next i
End Sub