About the Email function on OutSystems.

I would like you guys to give me some advice.

Is it possible to put a limitation on the following when we send the Email from the application?

1. To put a limitation on the Email size.

2. To put a limitation on the number of sending the Email.


Thank you for your advice.

Hey Yukiya

Are you looking to apply these rules to that certain application only or to your whole environment?

Ossama

Thank you for your reply, Ossama.

If possible, I would like to apply to the whole environment.

But it's okay to apply to the certain application if it's hard to do so.

Anyway, I don't have any idea how to extend the Email function. 

Any information is gonna be pretty helpful.


Thank you.


Ossama Ghanem wrote:

Hey Yukiya

Are you looking to apply these rules to that certain application only or to your whole environment?

Ossama



As far as I know, there isn't a built-in way to apply email limitations to the entire environment. The options listed under Administration -> Email in Service Center are the only variables you can configure however you might want to double check with OutSystems Support.

On the other hand, you can do some email validation within the logic of your application. 

To control the number of emails, you can define a a site property to hold the maximum number of allowed emails and define a counter (could be a site property too). Create a custom function to send emails which would take in the required fields to send an email (e.g. Subject, Content etc.). The function would check your counter and if you haven't exceed the maximum number of allowed emails (site property) then increment your counter and send the email.

Too take it a step further, you can make this function public and use it anywhere in your environment where you need to send an email (applying these rules environment-wide).

Regarding email size, I don't think there is an easy way of doing it however refer to this thread. You might be able to convert your email content to binary and get the size of that binary. You can then apply a rule to prevent sending the email if it exceeds a certain size.

Two observations:

  1. Never use site properties to hold counters, this will cause performance problems!
  2. What would you like to do when the max. number of e-mails are exceeded and/or a too large e-mail is to be sent? Silently failing to send e-mail could be disasterous!

To Ossama.

Thank you for your reply.


It seems to be difficult to realize what I want to do with Service Center...


>On the other hand, you can do some email validation within the logic of your application. 

I was considering the same thing.

Does the way you told me mean to extend the e-Mail API?



Ossama Ghanem wrote:

As far as I know, there isn't a built-in way to apply email limitations to the entire environment. The options listed under Administration -> Email in Service Center are the only variables you can configure however you might want to double check with OutSystems Support.

On the other hand, you can do some email validation within the logic of your application. 

To control the number of emails, you can define a a site property to hold the maximum number of allowed emails and define a counter (could be a site property too). Create a custom function to send emails which would take in the required fields to send an email (e.g. Subject, Content etc.). The function would check your counter and if you haven't exceed the maximum number of allowed emails (site property) then increment your counter and send the email.

Too take it a step further, you can make this function public and use it anywhere in your environment where you need to send an email (applying these rules environment-wide).

Regarding email size, I don't think there is an easy way of doing it however refer to this thread. You might be able to convert your email content to binary and get the size of that binary. You can then apply a rule to prevent sending the email if it exceeds a certain size.



Hi, Kilian.

Thank you for your reply.

>2.What would you like to do when the max. number of e-mails are exceeded and/or a too large e-mail is to be sent? Silently failing to >send e-mail could be disasterous!

I would like to stop sending a email.


Thank you.


Kilian Hekhuis wrote:

Two observations:

  1. Never use site properties to hold counters, this will cause performance problems!
  2. What would you like to do when the max. number of e-mails are exceeded and/or a too large e-mail is to be sent? Silently failing to send e-mail could be disasterous!



Solution

Hey Yukiya,


There's isn't a need to extend the email APIs. There is also no need to silently fail emails. I was referring to a simple action which would act as a checker before executing the Send Email action. 

Email Check Action

This action would live in an independent eSpace and made Public. The action would first check the email counter (which is managed in the same module) then check if the email size (Input parameter) is acceptable. If it passes these 2 checks, then the function would return True

Application Logic

You can then place this action before any Send Email action in you environment, ensuring all emails leaving your environment go through this check first. There will be some manual effort involved (especially if you've got a lot of Send Email actions) however this might be the best way to implement this environment wise.

To expand on this further, you could potentially add a screen to that independent module would would allow you to enter/change the "Max no of Emails" (Maybe manually reset it too?) and "Acceptable Email Size" values on the fly. 

Solution


Hi, Ossama.

Thank you very much for the well detailed implementation way.

Thanks to it, I could have imagined how  I realize  it.

Thanks again for your cooperation!



Ossama Ghanem wrote:

Hey Yukiya,


There's isn't a need to extend the email APIs. There is also no need to silently fail emails. I was referring to a simple action which would act as a checker before executing the Send Email action. 

Email Check Action

This action would live in an independent eSpace and made Public. The action would first check the email counter (which is managed in the same module) then check if the email size (Input parameter) is acceptable. If it passes these 2 checks, then the function would return True

Application Logic

You can then place this action before any Send Email action in you environment, ensuring all emails leaving your environment go through this check first. There will be some manual effort involved (especially if you've got a lot of Send Email actions) however this might be the best way to implement this environment wise.

To expand on this further, you could potentially add a screen to that independent module would would allow you to enter/change the "Max no of Emails" (Maybe manually reset it too?) and "Acceptable Email Size" values on the fly.