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 Me.txtBody > 0 Then
'If Len(Me.txtBody & vbNullString) > 0 Then
sBody = Me.txtBody
ElseIf 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,"
Else
sBody = "Hi" & " " & Me.txtFirstName & "," & vbCrLf & vbCrLf & "Here is the monthly invoice # for " & Me.txtCompany.Column(1) & "." & " " & "advise us if you would prefer to wire us payment to our updated <b> SVB USD Bank </b> account shown on the invoice, or if we may collect the payment from your Wallet account. " & vbCrLf & vbCrLf & "" & "Please contact me if you have any questions.Thanks,"
'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 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
.SentOnBehalfOfName = "AR@HYPERWALLET.COM"
.Display
'MsgBox "Remember to attach Invoice(s)", vbOKOnly, "Attach Invoice(s)"
End With
'oEmail.Body =
MailItem.HTMLBody = sBody
oEmail.Body = sBody
End Sub