Solved

Check attachements in Emails with more than one attachements


Badge +6
  • Contributor
  • 53 replies

To get a file validated, users can send an email to the FME-Server with the file attached. In an automation we first check, whether theres an attachement at all and whether the extension of the file is correct. If so, a validation-workpace starts, If not, the user gets an email back.

This works fine, as long as there's just one attachement. But we now have a user with a grafic-file in the email-signature. FME-Server counts that as attachement too and sends him a mail, that he has to send a file with the correct extension, even though the file is there...

I would have to loop through the attachements, if there were more than one, but how can I do this?

(We are using FME Server 2020.0.2.1)

 

Thanks in advance!

Vera

 

icon

Best answer by hollyatsafe 8 June 2021, 18:23

View original

4 replies

Badge +2

Hi @vki​ ,

When the Email trigger receives an email with a single attachment the event message JSON stores this in the "email.attachment" key. This is not a list feature, so cannot store multiple file paths, instead, if there are multiple attachments an additional key "email.attachments" is included in the JSON and this holds the file path to the folder where all the attachments are stored.

 

You can't control which attachment file path is stored in the single "email.attachment" key, so instead I'd recommend pointing your validation workspace to the folder + specify a wildcard to the correct file format so only this file triggers the job.

 

e.g.

{email.attachments}\\*.<extension>

 

Hi @vki​ ,

When the Email trigger receives an email with a single attachment the event message JSON stores this in the "email.attachment" key. This is not a list feature, so cannot store multiple file paths, instead, if there are multiple attachments an additional key "email.attachments" is included in the JSON and this holds the file path to the folder where all the attachments are stored.

 

You can't control which attachment file path is stored in the single "email.attachment" key, so instead I'd recommend pointing your validation workspace to the folder + specify a wildcard to the correct file format so only this file triggers the job.

 

e.g.

{email.attachments}\\*.<extension>

 

Hi Holly,

I've got a similar issue with multiple image attachments, when I only want to read an excel file (in an attached zip). I've implemented your suggestion above, but it's not working.

 

I'm passing {email.attachments}\\*.zip as a parameter to my feature reader. The result is that the file doesn't exist:

 

2022-11-30 10:56:40 | Excel Reader: Failed to open the dataset '/data/fmeserver/resources/temp/P_AU_MWF/Incoming Emails/20221130005640-mwf-lots-FW_EXT_GENACA-ACA0100_MWF_Work_Lots_[K3.1.11014A2C.784F9E0]-f5a86f7d-8181-4447-b38b-ef74209cd409/*.Zip'. Error message was 'File does not exist'

 

If I specify the filename of the zip in the parameter (I won't ever know this in future), it works. E.g. {email.attachments}\\thefilename.zip

 

Do you have any idea why the wildcard isn't working?

 

I'm using an automation in FME Server 2022.2

Hi Holly,

I've got a similar issue with multiple image attachments, when I only want to read an excel file (in an attached zip). I've implemented your suggestion above, but it's not working.

 

I'm passing {email.attachments}\\*.zip as a parameter to my feature reader. The result is that the file doesn't exist:

 

2022-11-30 10:56:40 | Excel Reader: Failed to open the dataset '/data/fmeserver/resources/temp/P_AU_MWF/Incoming Emails/20221130005640-mwf-lots-FW_EXT_GENACA-ACA0100_MWF_Work_Lots_[K3.1.11014A2C.784F9E0]-f5a86f7d-8181-4447-b38b-ef74209cd409/*.Zip'. Error message was 'File does not exist'

 

If I specify the filename of the zip in the parameter (I won't ever know this in future), it works. E.g. {email.attachments}\\thefilename.zip

 

Do you have any idea why the wildcard isn't working?

 

I'm using an automation in FME Server 2022.2

I should add, the zip file always has the character # in the filename.

e.g. ACA_MIP-GENACA-ACA#0097-attachedfile.Zip

 

Could this be the issue?

Hi @vki​ ,

When the Email trigger receives an email with a single attachment the event message JSON stores this in the "email.attachment" key. This is not a list feature, so cannot store multiple file paths, instead, if there are multiple attachments an additional key "email.attachments" is included in the JSON and this holds the file path to the folder where all the attachments are stored.

 

You can't control which attachment file path is stored in the single "email.attachment" key, so instead I'd recommend pointing your validation workspace to the folder + specify a wildcard to the correct file format so only this file triggers the job.

 

e.g.

{email.attachments}\\*.<extension>

 

Hi Holly,

 

I'm receiving a similar error as leon.bowers. Are there any suggestions for why the wild card might not work in this case?

Reply