Ihope someone can tell me what is wrong with this code.... I have a form that selects a student (Student ID and Student Name), organisation and email and I have a file that contains CV's saved as word documents (docx) using the student ID as the name.
What I am trying to do is use the fields on the form to open an email to the organisation and send the CV as an attachment. The code is struggling to find the document attachment.
[Private Sub Command95_Click()
Dim strPath As String
Dim strFilter As String
Dim strFile As String
strPath = "L:QLS Reports\Work Experience\CV\"
strName = Me.[Student ID]
strFilter = "*.docx"
strFile = Dir(strPath & strName & strFilter)
Set appOutLook = CreateObject("Outlook.Application")
Set MailOutLook = appOutLook.CreateItem(olMailItem)
Const olFormatHTML = 2
With MailOutLook
.BodyFormat = olFormatHTML
.To = [Forms]![Email CV].[OrgEmail1]
.cc = ""
.bcc = ""
.Subject = [Forms]![Email CV].[StuName]
.HTMLBody = "Please find CV attached for the above student"
Attachments.Add (strPath & strFile)
Display
End With
End Sub]
Thank you