I need to put a dialog box - File Browser (would it be Activex Control, if so, which one?) for picking the file to be attached to Outlook e-mail sent from Access form.
The Outlook part works OK and my script so far looks like this:
Private Sub btnEmail_Click()
On Error GoTo Err_btnEmail_Click
Dim Email As String
Dim Subject As String
Dim notes As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.To = Me.Email
.Subject = Me.Subject
.Body = "Dear" & Me.Title & " " & Me.FirstName & " " & Me.Surname & Chr(10) & Me.notes
'.Send
.Display
End With
Me.EmailSent = vbYes
Me.lblSent.Visible = True
Me.lblSent.Caption = "E-mail successfully sent"
Exit Sub
Screen.PreviousControl.SetFocus
DoCmd.FindNext
Exit_btnEmail_Click:
Exit Sub
Err_btnEmail_Click:
MsgBox Err.Description
Resume Exit_btnEmail_Click
objOutlook.Quit
Set objEmail = Nothing
End Sub
Can anybody assist, please?
The Outlook part works OK and my script so far looks like this:
Private Sub btnEmail_Click()
On Error GoTo Err_btnEmail_Click
Dim Email As String
Dim Subject As String
Dim notes As String
Dim objOutlook As Outlook.Application
Dim objEmail As Outlook.MailItem
Set objOutlook = CreateObject("Outlook.application")
Set objEmail = objOutlook.CreateItem(olMailItem)
With objEmail
.To = Me.Email
.Subject = Me.Subject
.Body = "Dear" & Me.Title & " " & Me.FirstName & " " & Me.Surname & Chr(10) & Me.notes
'.Send
.Display
End With
Me.EmailSent = vbYes
Me.lblSent.Visible = True
Me.lblSent.Caption = "E-mail successfully sent"
Exit Sub
Screen.PreviousControl.SetFocus
DoCmd.FindNext
Exit_btnEmail_Click:
Exit Sub
Err_btnEmail_Click:
MsgBox Err.Description
Resume Exit_btnEmail_Click
objOutlook.Quit
Set objEmail = Nothing
End Sub
Can anybody assist, please?