Skip to main content

Hello,

I have a flow automation set up to send out email with attachment(s) from a workspace. The output from the workspace include files: f1.xlsx, f2.kmz, and some parameter (e.g. ‘kmzneeded’ with value Yes/No).
The email will always send f1.xlsx, but depends on whether or not user draw on the map, then f2.kmz need to be attached. 
Right now, I configured to include the two file path in server in the email attachment ("$(FME_SHAREDRESOURCE_TEMP)/F1.xlsx" "$(FME_SHAREDRESOURCE_TEMP)/F2.kmz"), so it always emails two files (with incorrect kmz from previously run). 

Can anyone please help point me a direction how to handle this? 

Any information is appreciated. 🙏

I think there’s two approaches to consider:

  1. Do your emailing in the workspace itself, this requires the use of FeatureWriters instead of regular writers so you can use an Emailer transformer afterwards. Test if the geometry parameter is filled and based on that trigger the correct Emailer, one is set up to only do one attachment, the other will do both.
  2. Use the Automations writer to add output ports to the workspace action in the Automation, then based on that trigger separate Email actions. Again you need to test inside the workspace whetherthe geometry parameter is filled.

Thank you very much @redgeographics for your response. 

  1. No, I haven’t use the emailer inside workspace. I looked up the Emailer transformer info yesterday, still a little puzzled: do I have to use google gmail account to set up? is it possible use same email configuration set up as flow since the workspace will be used in flow automation. 
  1. Yes, I am using Automation. And I do have a parameter ‘kmzneeded‘ indicating the test result for geometry with possible value: Yes/No, right now it’s in the same port as other parameters like userEmail, userName…
    Do you mean I need to create a separate port just for this ‘kmzneeded‘ parameter? but how to trigger different email action based on this port’s output value?
    Or should I try to make the port ‘kmzneeded’ only available when it’s Yes within my workspace? Probably that’s what you mean… Sounds doable… will try it now! Thanks. 

I have tried, but some how still not quite right.

I created two separate port inside workspace, almost identical, except withKML has one more parameter devEmail (developer’s email). And with the flow automation configuration as following. 

I was hoping that

if geometry valid (both ports are valid), then user will get Email 1 only, and I myself get email 2. 

if geometry not valid, withKML port is not valid, then Email 2 will fail due to invalid email to, so the ‘x’ port can trigger Email 3 to email user the xlsx only email. 

It works with No geometry cases, only one email (Email3) with xlsx file was received. 

However, when geometry valid, I received two emails: Email 1 and Email 3…. 

I thought I should receive Email 2 myself, instead of Email 3 to users..

What have I done wrong? Is there any other way to handle this?

 

 


I updated my automation, 

Email 1 to: withKML.kmlEmailReceipients

Email 2 to: xlsxOnly.emailReceipients

still have similar issue. I still got both Email 2 and email 1 when withKML port valid. 

I am expecting if Email 1 works, then it won’t trigger Email 2. but somehow I got both..

Anyone know what I did wrong? How to debug? I check my log file did not see any error message associated with emailing..


Finally seems get it to work. I post my approach here in case someone else may find it helpful.

In workspace, I created two fields ‘kmlEmail’ and ‘xlsxEmail’, based on field ‘kmlneeded’ Yes/No value, set kmlEmail to emailRecipients, or ‘NA’. Similar for ‘xlsxEmail’:  when kmlneeded = Yes, xlsxEmail = ‘NA’, else xlsxEmail get whatever in emailRecipients. 

Email 1 to: xlsxOnly.kmlEmail; with two attachments: f1.xlsx, f2.kml

Email 2 to: xlsxOnly.xlsxEmail; with only f1.xlsx

so, when kmlneeded, Email 1 got triggered, two attachment will be sent to emails listed under kmlEmail;  in case Email 2 still get triggered (although though it should not, but it did for some reason), but email 2 recipients were from xlsxEmail, which is ‘NA for now, so no email will be sent.

if no kml, then email 1 will fail with ‘NA’ in To: ; then Email 2 will be triggered, and will send just xlsx file to users.

This implementation don’t need two different port. ‘withKML’ port can be removed. 


Good to hear you got it sorted out. I was offline for the evening (time zones, yay!)

 

I must say I am not a fan of deliberately causing the Email action to fail with an erroneous To: setting. If you want to dive deeper into it, it would be useful to see how the Automations writer is set up inside the workspace. One thing that you may have overlooked is that you can create attributes on the feature types of the Automations writer and they will become user keys that you can use in subsequent automation items.

But if you say: “it works, so don’t touch it” I totally understand.


An alternative approach is to configure the list of attachments within the workspace and send that to an automations writer. You can then use that key as the attachment list in the email action

E.g. in your workspace this

then in the automation

 


Good to hear you got it sorted out. I was offline for the evening (time zones, yay!)

 

I must say I am not a fan of deliberately causing the Email action to fail with an erroneous To: setting. If you want to dive deeper into it, it would be useful to see how the Automations writer is set up inside the workspace. One thing that you may have overlooked is that you can create attributes on the feature types of the Automations writer and they will become user keys that you can use in subsequent automation items.

But if you say: “it works, so don’t touch it” I totally understand.

Ha, I was  thinking of those errors on the server as well. That bothers me. I thought it got be some other approaches. 

Thanks for the inputs. I will try and update if I switch to another approach. 


An alternative approach is to configure the list of attachments within the workspace and send that to an automations writer. You can then use that key as the attachment list in the email action

E.g. in your workspace this

then in the automation

 

Yes, this approach sounds more nature than my erroneous email actions. 

I will try this. Thank you so much!  


An alternative approach is to configure the list of attachments within the workspace and send that to an automations writer. You can then use that key as the attachment list in the email action

E.g. in your workspace this

then in the automation

 

 

So sad…. I just lost all my content I typed in here when hit ‘Send”.😭

Have to write it again..

I have this approach partially working.. For some reason, I only be able to get the attachements work when the field only contains one value, either $(FME_SHAREDRESOURCE_TEMP)/TE_HSIP_EA/HSIP_Data.xlsx 

or  $(FME_SHAREDRESOURCE_TEMP)/TE_HSIP_EA/projectLine.kml

When I tried to get both in one field (with or without “ “), it won’t send any attachments (I got the email though). 

How to get the two paths into the field? 

 


What a struggle, but finally get it resolved…

I tried the attachment approach, did not quite work out, (can have the two files attached programmatically, I probably did not do the right way.)

Finally dive deeper into automation writer, and configure workspace to output two ports, withKML and xlsxOnly, workspace will only activate one port a time.

then in the automation, withKML has email with two attachments (added from flow), while xlsxOnly email only one attachment. 

 

 

Thanks @redgeographics, @ebygomm. Great learning experience for me.   


Reply