Private Sub Send_Email_Click()
Dim email As String
Dim REF As String
Dim Body As String
Dim strAttach As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Dim objOutlookAttach As Outlook.Attachment
Dim strMsg As String
Dim blAttachment As Boolean
On Error GoTo ErrorMessage
email = Me![Borrower_Email_Address]
REF = Me![Email_Reference]
Body = Me![Email_Body]
If Not IsNull(Me.attachment_name) Then
strAttach = Me![attachment_name]
blAttachment = True
Else
blAttachment = False
End If
Set objOutlook = CreateObject("Outlook.Application")
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.To = email
.Subject = REF
.SentOnBehalfOfName = "ADE NO HR SH"
' ******************************
' HERE IS WHERE I WANT THE CODE!
' ******************************
.Body = Body
If blAttachment = True Then
.Attachments.Add strAttach
End If
.Send 'sends the email in Outlook
End With
Set objEmail = Nothing
ErrorMessage:
MsgBox Err.Description
End Sub
|