Log in

View Full Version : sending more recent documents, different types, in one mail



le_marc0507
10-04-2018, 12:06 AM
First of all, thanks to everyone who would help me because I'm new to this programming. I would like to create a macro (_onClick) in the MS Word document, which will enclose 2 or more recently created documents from the same folder with a different extension (.zip, .txt, .xls) in the mail and will be in one mail. Each requested file starts with "EXAM"
Can anyone help this beginner?
Tnx

le_marc0507
10-04-2018, 05:40 AM
First of all, thanks to everyone who would help me because I'm new to this programming. I would like to create a macro (_onClick) in the MS Word document, which will enclose 2 or more recently created documents from the same folder with a different extension (.zip, .txt, .xls) in the mail and will be in one mail. Each requested file starts with "EXAM"
Can anyone help this beginner?
Tnx

le_marc0507
10-04-2018, 06:37 AM
This solution is primal but works. Can someone help me and simplify this

....

' Check date on each file on each extension in folder.
For Each objFile In objFolder.Files
If objFile.DateLastModified > varDate And objFSO.GetExtensionName(objFile) = "zip" And Left(objFile.Name, 5) = "EXAM" Then
varDate = objFile.DateLastModified
strName = objFile.Name
End If
Next

For Each objFile1 In objFolder1.Files
If objFile1.DateLastModified > varDate1 And objFSO.GetExtensionName(objFile1) = "txt" And Left(objFile1.Name, 5) = "EXAM" Then
varDate1 = objFile1.DateLastModified
strName1 = objFile1.Name
End If
Next

With OutMail
.to = ""
.CC = ""
.BCC = ""
.Subject = ""
.Body = ""
.Attachments.Add (strPath & strName)
.Attachments.Add (strPath & strName1)
.Display
End With