I'm having trouble figuring out how to handle an email error. Current error is invalid email address for the Send To.
On my email resource I had the Success of the email is critical flag checked which caused my workflow task to be marked as failed, which is correct. If I uncheck that box and run the workflow, the sendemail call always returns true, even though the email fails.
How can I handle the failed state and do something? Ultimately I want to go to a different task to send an email and then reassign a previous task. I've got that part done, just need to handle the email resource failing.
How to handle error from sending an email
Moderators: Jon, Steve, Ian, Dave
-
- Ebase User
- Posts: 19
- Joined: Tue Oct 03, 2017 3:33 pm
- Location: USA
-
- Moderator
- Posts: 1342
- Joined: Wed Sep 12, 2007 12:49 pm
Re: How to handle error from sending an email
If you're using Javascript have a look at the Javadoc for sendmail. When the email resource is not marked as critical it will return false when the email fails. So you can code something like:
Alternatively, if it's marked as critical, an exception is throws. So you need:
If you're using FPL, don't mark the email resource as critical, then check the response from sendmail is "OK".
Code: Select all
if (!resources.myemail.sendmail())
{
.. handle the error
}
Code: Select all
try
{
resources.myemail.sendmail()
}
catch (e)
{
..handle the error
}
0 x
-
- Ebase User
- Posts: 19
- Joined: Tue Oct 03, 2017 3:33 pm
- Location: USA
Re: How to handle error from sending an email
I'll try it using your syntax. When I tried before turning off that flag it was always return true.
0 x
-
- Ebase User
- Posts: 19
- Joined: Tue Oct 03, 2017 3:33 pm
- Location: USA
-
- Ebase User
- Posts: 19
- Joined: Tue Oct 03, 2017 3:33 pm
- Location: USA
Re: How to handle error from sending an email
Wait, I typed too fast.
The call to the sendmail is always returning true, even when sending to an invalid email address.
The call to the sendmail is always returning true, even when sending to an invalid email address.
0 x
-
- Ebase User
- Posts: 19
- Joined: Tue Oct 03, 2017 3:33 pm
- Location: USA
Re: How to handle error from sending an email
I set up a simple form with fields and an email resource. I tried both of the below snippets, but the sendmail never returned a false nor an error. Yet I get an email bounced back error to the inbox that my email settings are using.
try
{
resources.VelocityEmail.sendmail()
}
catch (e)
{
print("Error Occurred")
}
or
if (!resources.VelocityEmail.sendmail())
{
print("Error Occurred")
}
try
{
resources.VelocityEmail.sendmail()
}
catch (e)
{
print("Error Occurred")
}
or
if (!resources.VelocityEmail.sendmail())
{
print("Error Occurred")
}
0 x
-
- Ebase User
- Posts: 649
- Joined: Mon Dec 09, 2013 6:37 pm
Re: How to handle error from sending an email
It sounds like if its bouncing back to the sender it means that as far as Ebase is concerned, it was correctly delivered but its getting bounced back by the email server. This is an entirely different issue that you won't be able to catch in Ebase
0 x
-
- Ebase User
- Posts: 19
- Joined: Tue Oct 03, 2017 3:33 pm
- Location: USA
Re: How to handle error from sending an email
Ah crud, that sounds about right.
Luckily I think I have a work around.
Thanks
Luckily I think I have a work around.
Thanks
0 x
Who is online
Users browsing this forum: No registered users and 2 guests