Get attachment filename

Added a new function, removed bad functionality, and reordered parameters.