Hello all,
Pulling my hair out. I have an email function that works perfectly and I'd prefer not to deviate from it (but will if I have to). However, I'm trying to get the proper name of the attachment I am sending out, currently it's attached as "ProposalReport" where I need it to by the job name and company name (ABC Company Job Name.pdf) which is saved as in a folder on the shared drive. I have tried several things, but just can't get it right. I'm sure it has to do with the line: ObjectName:="ProposalReport", I've tried rewriting it to grab the name of the pdf, but no go.
Code:
Dim stDocName As String
Dim MyPath As String
'MyPath = (Forms!currentjobs!networkpath & "\" & JobID & " " & JOBNAME & "\Proposals\")
Dim myreport As String
MyPath = ([Forms]![currentjobs]![saveto] & "\" & [Forms]![currentjobs]![JOBID] & " " & [Forms]![currentjobs]![JOB NAME] & "\Proposals\" & Forms!currentjobs!GCTABLE1.Form.[gc1name])
stDocName = "ProposalReport"
myreport = Forms!currentjobs!GCTABLE1.Form.[reportname]
DoCmd.OutputTo acReport, stDocName, acFormatPDF, MyPath + ".pdf", True
'DoCmd.OutputTo acReport, "proposalreport", acFormatPDF, MyPath + ".pdf", True
'MyPath = (Forms!currentjobs!FullPath + gc1name + JOBNAME)
DoCmd.OutputTo acReport, stDocName, acFormatPDF, MyPath + ".pdf", True
Dim lngCurrentRow As Integer
Dim strTo As String
'Dim strCC As String
'Dim strBCC As String
Dim bOK As Boolean
Dim strsubject As String
Dim strmessagetext As String
strsubject = "Proposal Attached"
strmessagetext = Forms!currentjobs!GCTABLE1!gc1name & ":" & _
vbNewLine & vbNewLine & _
"UAC Proposal Request is attached." & _
vbNewLine & vbNewLine & _
"UAC Proposal"
strTo = Forms!currentjobs!GCTABLE1!Email
DoCmd.SendObject ObjectType:=acSendReport, _
ObjectName:="ProposalReport", _
OutputFormat:=acFormatPDF, _
To:=strTo, _
Subject:=strsubject, _
messagetext:=strmessagetext, _
EditMessage:=True
'Call SendMsg(strsubject, strmessagetext, strTo)
Exit_EmailProposals_Click:
Exit Sub
Err_EmailProposals_Click:
MsgBox Err.Description
Thanks in advance for any advice you can offer!