I have an Access XP form that makes multiple pdf reports and saves them to a folder depending on what the log number is. All of the code works as it should to create the reports and save them but I need to attach them to an email afterwards. I don't know how to write the code to attach every file in the folder if I don't know how many there will be or what the file names will be each time. This is the code that I am trying to use and I get an error trying to use and asterick.
Dim rs As Object, rsLogNo As String
' I use this table to get the Log Number to use in the loop which is the name of the folder the code creates in N:\LCM
Set rs = CurrentDb().OpenRecordset("tblLogNumbers")
Dim appOutlook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutlook = CreateObject("Outlook.Application")
Set MailOutLook = appOutlook.CreateItem(olMailItem)
rs.movefirst
Do While Not rs.EOF
rsLogNo = rs.LogNo
With MailOutLook
.To = "lprice@somewhere.com"
.CC = ""
.BCC = ""
.Subject = rsLogNo
.Body = "Test"
.Attachments.Add "N:\LCM\" & rsLogNo & "*.pdf"
.Send
End With
rs.MoveNext
Loop
Set rs = Nothing
If you need the complete code I use for creating the folders and pdf reports I will post although it is long.
Thanks
Lisa
Dim rs As Object, rsLogNo As String
' I use this table to get the Log Number to use in the loop which is the name of the folder the code creates in N:\LCM
Set rs = CurrentDb().OpenRecordset("tblLogNumbers")
Dim appOutlook As Outlook.Application
Dim MailOutLook As Outlook.MailItem
Set appOutlook = CreateObject("Outlook.Application")
Set MailOutLook = appOutlook.CreateItem(olMailItem)
rs.movefirst
Do While Not rs.EOF
rsLogNo = rs.LogNo
With MailOutLook
.To = "lprice@somewhere.com"
.CC = ""
.BCC = ""
.Subject = rsLogNo
.Body = "Test"
.Attachments.Add "N:\LCM\" & rsLogNo & "*.pdf"
.Send
End With
rs.MoveNext
Loop
Set rs = Nothing
If you need the complete code I use for creating the folders and pdf reports I will post although it is long.
Thanks
Lisa