Is use code below to create mail and add "default" attachments.
Now I want to add attachments with loop. Depending of availability.
For that I created query to check if pdf file excists.
How can I change my code to add a loop to add additional attachments?
Code:
Public Function mailPDFReport2()
Dim MyOutlook As New Outlook.Application
Dim Item As Outlook.MailItem
Dim sReport As String
Dim namePath As String
Dim FileName As String
Dim rpt As Access.Report
Subjectline$ = InputBox$("Please enter the subject line for this mailing.", "We Need A Subject Line!")
sPath = Application.CurrentProject.Path & "\"
sReport = "rptOffer2"
FileName = "Offer.pdf"
namePath = sPath & FileName
DoCmd.OutputTo objecttype:=acOutputReport, objectname:=sReport, outputformat:=acFormatPDF, outputfile:=namePath, autostart:=False
Set Item = MyOutlook.CreateItem(mItem)
With Item
Item.To = ""
Item.Subject = Subjectline$
Item.Body = BodyFile$
Item.Attachments.Add namePath
Item.Attachments.Add "\\SERVER01\Dokumenten\DB\BE\General Terms Of Sale.pdf"
Item.Display
End With
End Function
Now I want to add attachments with loop. Depending of availability.
For that I created query to check if pdf file excists.
Code:
strSql = "SELECT QryOfferExtended.ProductSpecFile " & vbCrLf & _ "FROM QryOfferExtended " & vbCrLf & _
"WHERE (((QryOfferExtended.ProductSpecFile) Is Not Null And (QryOfferExtended.ProductSpecFile)<>""""));"
How can I change my code to add a loop to add additional attachments?