I have browse button to attach multiple files, even if I select multiple files and only show one in the textbox attachment, if add this line more than once on the send button,
when click send it repeats same file,
how can i select multiple files to send.
here are the codes:
Browse Button:
Send Button:
thanks
Code:
oEmail.Attachments.Add Me.txtAttachment.Value
how can i select multiple files to send.
here are the codes:
Browse Button:
Code:
Private Sub btnBrowse_Click()
Dim fileDiag As FileDialog 'BROWSE BUTTON
Dim strFile As String
Dim strFolder As String
Dim file As Variant
Set fileDiag = FileDialog(msoFileDialogFilePicker)
fileDiag.AllowMultiSelect = True
If fileDiag.Show Then
For Each file In fileDiag.SelectedItems
Me.txtAttachment = file
Next
End If
End Sub
Send Button:
Code:
Private Sub btnSend_Click()
Dim oApp As New Outlook.Application
Dim oEmail As Outlook.MailItem
Dim sBody As String
Set oEmail = oApp.CreateItem(olMailItem)
If IsNull(Me.txtTo) Then ' No email address
MsgBox "Please Select a Customer, if the email field is empty, then edit the customer and add the email by clicking the Edit Customer button at the bottom!", vbOKOnly, "Add the Email address" ' Tell user
Me.txtCompany.SetFocus ' Focus the control
Exit Sub
Else
oEmail.To = Me.txtTo
oEmail.CC = Me.txtCCEmail & ";" & Me.txtCCEmail2
oEmail.BCC = "ar@hyperwallet.com"
End If
' Exit the method
If txtSubject > 0 Then
oEmail.Subject = Me.txtSubject
Else
oEmail.Subject = Me.txtCompany.Column(1) & " " & "-" & " " & "Invoice #"
End If
If txtBody >= 0 Then
sBody = Me.txtBody
Else
sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "Please confirm if we may collect the payment from your wallet. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"
End If
If Forms![Contact Details]![Auto Collect] = True Then
sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & " As per your instructions we will withdraw the amount from your loading wallet. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"
End If
' sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "Please confirm if we may collect the payment from your wallet. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"
'oEmail.Body =
If Len(Me.txtAttachment) > 0 Then
oEmail.Attachments.Add Me.txtAttachment.Value
End If
With oEmail
' If Not IsNull(.To) And Not IsNull(.subject) And Not IsNull(.Body) Then
.Display
' MsgBox "Remember to attach Invoice(s)", vbOKOnly, "Attach Invoice(s)"
End With
oEmail.Body = sBody
End Sub
thanks