use OutputTo to create the file with the correct filename.
then send it as an attachment via Outlook (or other email)
sub MakeRpt()
vRpt ="Reporte de No Conformidad " & Me.Code 'This is the name I want to call my file
vFile = "c:\folder" & vRpt & ".pdf"
'put the report into a file
docmd.OutputTo acOutputReport ,"rMyReport",acFormatPDF,vFile
'send that file
Send1Email "bob@aol.com", "your report","here is the report", vfile
end sub
Code:
'-------
'YOU MUST ADD THE OUTLOOK APP IN REFERENCES!!! checkmark OUTLOOK OBJECTS in the vbE menu, Tools, References
'-------
Public Function Send1Email (ByVal pvTo, ByVal pvSubj, ByVal pvBody, optional pvFile ) As Boolean
Dim oApp As Outlook.Application
Dim oMail As Outlook.MailItem
On Error GoTo ErrMail
Set oApp = CreateObject("Outlook.Application")
Set oMail = oApp.CreateItem(olMailItem)
With oMail
.To = pvTo
.Subject = pvSubj
.Body = pvBody
if not IsMissing(pvFile) then .Attachments.Add pvFile, olByValue, 1
.Send
End With
Email1 = True
Set oMail = Nothing
Set oApp = Nothing
Exit Function
ErrMail:
MsgBox Err.Description, vbCritical, Err
Resume Next
End Function