- + Load email from template (body, distribution list and so)
- + Look for newest PDF file in set directory
- + Attach that PDF file
- + Set subject and add date
- ============================================================
- Sub MOM()
- ' You need to set a reference to the scripting object
- Dim objMail As Outlook.MailItem
- Dim fso As Scripting.FileSystemObject
- Dim strFile, sNew As String, dtNew As Date
- Set fso = New Scripting.FileSystemObject
- strFile = "Z:\11 Admin\02 Operations\05 MoMs"
- Set fsoFldr = fso.GetFolder(strFile)
- For Each fsoFile In fsoFldr.Files
- ' check the extension and age
- If fsoFile.DateLastModified > dtNew And Right(fsoFile.Name, 4) = ".pdf" Then
- sNew = fsoFile.Path
- dtNew = fsoFile.DateLastModified
- Debug.Print sNew & dtNew
- End If
- Next fsoFile
- 'Create e-mail item
- Set objMail = Application.CreateItemFromTemplate("C:\Users\Administrator\AppData\Roaming\Microsoft\Templates\MOM.oft")
- With objMail
- .BodyFormat = olFormatHTML
- .Subject = "Minutes of Meeting " & Format(Date, "dddd dd-mm-yyyy")
- .Attachments.Add sNew
- .Display
- End With
- End Sub
Recent Pastes