Hi: I have noticed a problem in some new code I did on one of our productions. I think it is leading to 2 problems.  I have a file, lets call it 1111111111_2300.pdf.  We make the file UNIQUE to avoid an issue. This filename in the working directory gets a session ID Added to it before the .pdf. So lets say it was session ID 9 it would be 1111111111_2300#SID9.pdf in a working directory .  There are further operations to be done on this document before it is sent. For various errors an **email** is sent back to service users.  Now as part of being really clear that this document was the one that was sent, the attachment should be called 1111111111_2300.pdf.  how best can i attach the file 1111111111\_2300#SID9.pdf to display names in the email as 1111111111\_2300.pdf Set tSC = msg.AttachFile($P(fileToAttach,"\",1,*-1),$P(fileToAttach,"\",*)) The code I have currently is incorrect. It calls this  Set newFile = $P(file,"#SID")_".pdf"
If ##class(%File).CopyFile(file,newFile,1) </p>

The problem being

There must be a simplier way to do what our requirement is? 

</body></html>