This code works perfectly by opening a window and allowing you to select which file to attach to an email, but I'm looking to modify it so it automatically selects file types of my choosing (or even them all using *.* for all). Then to attach without having to press "Open" on the browse window.
'On Error GoTo SNDCLM_Click_Err
'Open Directory for current record report and allow user to select files to send within the email to teh address Specified
'Operates from Send Claim Button on Claims entry form
Dim oLook As Object
Dim oMail As Object
Dim FD As Object
Dim vrtSelectedItem As Variant
Dim strname As String
'strname = Application.CurrentProject.Path & "\" & Me.VHID.Column(1) & "\" & "Fault" & "\" & Me.CLID & "\" & Me.CLID & ".pdf"
'strname = "C:\Temp2\Test\*.pdf"
strname = "C:\Temp2\Test\"
Set oLook = CreateObject("Outlook.Application")
Set oMail = oLook.createitem(0)
Set FD = Application.FileDialog(3)
With oMail
.to = "enter@email.com"
.body = "Please see attached Claim Submission & Images."
.Subject = "XXXXXXXXXX"
FD.AllowMultiSelect = True
FD.Filters.Clear
FD.Filters.Add "All Files", "*.*"
FD.InitialFileName = strname
If FD.Show = True Then
For Each vrtSelectedItem In FD.SelectedItems
.Attachments.Add vrtSelectedItem
Next
End If
.Display
End With
Set FD = Nothing
Set oMail = Nothing
Set oLook = Nothing
'SNDCLM_Click_Exit:
Exit Sub
'On Error GoTo SNDCLM_Click_Err
'Open Directory for current record report and allow user to select files to send within the email to teh address Specified
'Operates from Send Claim Button on Claims entry form
Dim oLook As Object
Dim oMail As Object
Dim FD As Object
Dim vrtSelectedItem As Variant
Dim strname As String
'strname = Application.CurrentProject.Path & "\" & Me.VHID.Column(1) & "\" & "Fault" & "\" & Me.CLID & "\" & Me.CLID & ".pdf"
'strname = "C:\Temp2\Test\*.pdf"
strname = "C:\Temp2\Test\"
Set oLook = CreateObject("Outlook.Application")
Set oMail = oLook.createitem(0)
Set FD = Application.FileDialog(3)
With oMail
.to = "enter@email.com"
.body = "Please see attached Claim Submission & Images."
.Subject = "XXXXXXXXXX"
FD.AllowMultiSelect = True
FD.Filters.Clear
FD.Filters.Add "All Files", "*.*"
FD.InitialFileName = strname
If FD.Show = True Then
For Each vrtSelectedItem In FD.SelectedItems
.Attachments.Add vrtSelectedItem
Next
End If
.Display
End With
Set FD = Nothing
Set oMail = Nothing
Set oLook = Nothing
'SNDCLM_Click_Exit:
Exit Sub