Get Filename not working

Shortcuts advice pls. How do I grab the file name of an email attachment? I open the pdf to view it, then I run my Shortcut. It downloads the attachment, But the name changes to “PDF document.” If I save file to iCloud first, and THEN get the name (different shortcut), it works fine. Appreciate any help.

Try using the content graph action to verify that the name is actually being passed in by your e-mail app when the attachment is shared via the share sheet.

First, thanks for the input! The content graphic shows that the pdf is being passed through with the name “PDF Document “. Doesn’t make sense since the file has a real name. I notice that if I use the content graphic on a similar Shortcut that pulls from iCloud Drive Instead of email, what comes through is the real name of the pdf.

Here is a snapshot of what the content graphic shows. You have to click the photo to see all three photos:

The file has a “real name” in the e-mail, but it suggests that the original e-mail app is passing the data on to Shortcuts with a generic name. It’s about how the sharing app has been coded.

For example, if I use Spark as the client app to share from, it passes the PDF file with it’s original file name. If I use Apple’s mail app with the same file, from the same e-mail, to the same shortcut, it comes through with a generic name and there’s no sign of the original name anywhere in the content graph.

I’m going to assume that you are using the stock Apple mail app and suggest trying this. Long press on the attachment and select Quick Look. Then share from Quick Look to your Shortcut. Quick Look gets passed the file with its original name and is more respectful about handing it off to other apps like Shortcuts.

Hopefully that’ll help.

You diagnosed it perfectly! It works in Spark, it doesn’t work in the stock mail app, unless you use quick look. I see you post and help a lot of people. For what it’s worth, and on behalf of the group, Thanks so much for your expertise and help!