Using CnSmtpConnection for mail - error handling

For questions and postings not covered by the other forums
ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Using CnSmtpConnection for mail - error handling

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:08 pm

by NZWTA >> Fri, 24 May 2002 3:22:58 GMT

We are changing to use CardSchema to send mail. Im using userNotification to check for message completion and have subclassed CnSmtpConnection (as recommended in documentation). For a valid message this seems to be working fine. I have written an exception handler which also seems to be working OK. My problem is that validation errors raise an exception but dont seem to cause a user notification as well - and the documentation indicates they should. Is there something extra I need to do to raise the exception for the error?

ConvertFromOldNGs
Posts: 5321
Joined: Wed Aug 05, 2009 5:19 pm

Re: Using CnSmtpConnection for mail - error handling

Postby ConvertFromOldNGs » Fri Aug 07, 2009 12:08 pm

by cnwrca1 >> Mon, 27 May 2002 5:28:33 GMT

The documentation does not distinguish between validation that occurs before the message is sent, and validation that occurs during transmission.

If validation fails before the message is even sent (for example, because you forgot to set the sendFrom property), you will get a CnSmtpConnectionException, but you will not get a completion notification.
If validation fails during transmission (for example, because an allegedly ASCII attachment is found to contain non-ASCII characters), you will get a CnSmtpConnectionException, and also a completion notification.

In the latter case, a dialogue has already been established with the mail server, and the CnSmtpConnection object has to abort the dialogue according to the rules of the protocol. In the former case, no dialogue has been established.

The original thinking was that completion notification is only applicable once the transmission has started, but I agree that it would be more symmetrical if it applied in both cases.
Is there something extra I need to do to raise the exception for the error?

You could cause the completion event yourself in your exception handler:
exObj.mySmtpConnection.causeEvent(CnSmtpConnection.Completion_Event_Type, true, null);

where exObj is an exception of type CnSmtpConnectionException.

If you need more help, please contact me directly at rarzoni@jade.co.nz .
Regards,
Robin


Return to “General Discussion”

Who is online

Users browsing this forum: No registered users and 32 guests