Posted by pward in SWF Studio V3 on Oct 30 2008, 03:45 pm

Hello Support,

I've developed an application using FlexBuilder 3 & PureMVC (2.04) framework. The app sends emails using the ssCore.Email.send() and most of the time it functions perfectly. It'll send emails with one to many attachments just fine. But sometimes (not often) when the app executes ssCore.Email.send, instead of sending the email, the entire application just quits, shuts down closing itself. Whatever triggers this condition, it'll continue to behave this way unless I restart my workstation. Hopefully some else has come across this before and can share their wisdom/solution with me. One thing is that I'm not specifying the server (as shown in the code below). Should that parameter be left out completely if it isn't going to be explicitly set? Any feedback or help would be greatly appreciated. Thanks

P

 
try {
   ssCore.Email.send(
     {
       from: fromEmail.text,
       to: toEmailInputText.text,
         subject: subjectInputText.text,
         body: rte.text,
         server: "",
         bodyFormat: "HTML",
         headers: "",
         attachments: _fileLoc,
         importance: priority
     },
   {
     callback: onSendComplete
   });  
}
catch($e:Error)
{
   ssDebug.trace("SEND generic email error: " + $e );
}
            
// This function is called when the above Email.send() completes.
function onSendComplete(return_obj:Object, callback_obj:Object,error_obj:Object):void
{
   if (return_obj.success)
   {
      //execute code
   }
}


Posted by northcode in SWF Studio V3 on Oct 30 2008, 04:06 pm

Any parameter that's marked as optional can be left out, you don't have to supply a value for it.

ssCore.Email.send doesn't throw an error so there's nothing to catch. Whether it fails or is successful your callback function will always be called. I don't know if the exception handler is messing things up in that case or not. I'd recommend taking it out, it's unnecessary in that situation. Instead, set up your callback function like this:


function onSendComplete(return_obj:Object, callback_obj:Object,error_obj:Object):void
{
   if (return_obj.success)
   {
      //execute code
   }
   else
   {
      ssDebug.trace("send failed: " + return_obj.Error.description);
   }
}


Posted by pward in SWF Studio V3 on Oct 31 2008, 08:52 am

Thanks for the reply. I'll give that and if the behavior continues, at least I'll have the ssDebug.trace going for me to assist in further debugging. On a related note, sometimes the send email would fail, but instead of quitting the application, I had text display the error message and it would read

'Email failed to send. Error code::13, Send failed %2e'

Would you be able to tell me what Error code:: 13 refers to? That might / possibly help me isolate the problem.

Thanks again!
P


Posted by northcode in SWF Studio V3 on Oct 31 2008, 09:35 am

Error code 13 is a generic error that's returned if the send operation fails. Not so helpful. We have more information, we're just not exposing it right now. I'll make sure that gets fixed.


Posted by pward in SWF Studio V3 on Oct 31 2008, 10:15 am

Thanks again for the reply, at least I know Error Code 13 is generic.
Happy Halloween :batman:

Cheers,
P


Posted by pward in SWF Studio V3 on Oct 31 2008, 10:37 am

Update:
I've removed the try/catch and any/all optional params that weren't being explicitly set, and updated the callback function to trace the potential error/failure result messages. However in testing, the app still will crash (rarely) when the email is sent, and before it reaches the callback function. Thus no ssDebug.trace for assistance. The only piece of code executed before the sendEmail is just the Flex CursorManager.setBusyCursor(); which is removed once the callback function is called. It was doubtful this was causing an error, I commented it out and the results were the same. If there is anything else you could possible recommend, it would be appreciated. Thanks again

P


Posted by AGo in SWF Studio V3 on Nov 01 2008, 05:24 am

well, time for some serious debugging ;)

Use the debug swf as your main movie and set SWF Studio to use the Flash Debug player, and then go hunting with the debugger to check which line exactly fails.

Sometimes it´s already enough to only compile the debug exe, eventualy that will throw a runtime error that sets you on the right track (that has happend quite a few times before)

If you have pinpointed that the email.send function is to blame (e.g. the debugger crashed while the calling stack shows that some code inside of ssCore is executed) fire up a network sniffer so you might get to know which command where already send and which are supposed to be send at the time of the crash, that most likely will help northcode to get this one fixed.

ahh btw, of course try recompiling with the newsest SWF Studio build, which was released like last week (don´t know the exact date)


Posted by pward in SWF Studio V3 on Nov 03 2008, 01:39 pm

Thanks AGo for the suggestions. I've updated to V3.6 and have the 'serious' debugging setup and ready to go the next time this behavior occurs (hopefully it doesn't return). I'll update this thread if I discover any useful information that should be shared.

P