Eric Penfold
Active Member
- Joined
- Nov 19, 2021
- Messages
- 431
- Office Version
- 365
- Platform
- Windows
- Mobile
With this code the last part of Send Email FSOFile says "FSOFile" rather than the path and name of file??
Main Code below
End Sub
VBA Code:
For Each FSOFile In FSOFolder.Files
If (FSOFile.Name Like "*" & ".pdf" Or FSOFile.Name Like "*" & ".STEP" Or FSOFile.Name Like "*" & ".DXF") Then
Call Send_Email("Me.Email_List.Value", "", "", "Me.Enter_Number.Value" & " " & Format(Date, "dd/mmmm/yyyy"), _
"Process Frost Drawings", "FSOFile")
End If
Next FSOFile
Main Code below
VBA Code:
Sub Send_Email(EmailTo As String, EmailCC As String, EmailBCC As String, EmailSubject As String, EmailBody As String, EmailAttachment As String)
Dim EmailApp As Object
Dim EmailItem As Object
Dim Source As String
Set EmailApp = CreateObject("Outlook.Application")
Set EmailItem = EmailApp.CreateItem(0)
With EmailItem
.to = EmailTo
.CC = EmailCC
.BCC = EmailBCC
.Subject = EmailSubject
.Body = EmailBody
If EmailAttachment <> "" Then
.Source = EmailAttachment
EmailItem.Attachments.Add Source
End If
.Display
'EmailItem.Send
End With
End Sub
Private Sub Email_Drawings_Click()
Dim EmailApp As Object
Dim EmailItem As Object
Dim Source As String
Dim FSOLibary As FileSystemObject
Dim FSOFolder As Object
Dim FSOFile As Object
Dim strFolderCriteria As String, FolderName As String, strPath As String, strEmailTo As String
Dim FilesToSend As String
Set EmailApp = CreateObject("Outlook.Application")
Set EmailItem = EmailApp.CreateItem(0)
strFolderCriteria = (Me.Enter_Number.Value)
strPath = "\\DF-AZ-FILE01\Company\R&D\Drawing Nos\Frost Grates"
FolderName = strPath & "\" & strFolderCriteria & "\"
Set FSOLibary = New Scripting.FileSystemObject
Set FSOFolder = FSOLibary.GetFolder(FolderName)
For Each FSOFile In FSOFolder.Files
If (FSOFile.Name Like "*" & ".pdf" Or FSOFile.Name Like "*" & ".STEP" Or FSOFile.Name Like "*" & ".DXF") Then
Call Send_Email("Me.Email_List.Value", "", "", "Me.Enter_Number.Value" & " " & Format(Date, "dd/mmmm/yyyy"), _
"Process Frost Drawings", "FSOFile")
End If
Next FSOFile
End Sub