I would like to make a suggestion to the InfoPath development team. At present an EmailSubmitConnection will basically always throw a WebException which is empty apart from a very generic message which is often useless.
This occurs when submitting from code or by using the data connection directly. It is especially annoying if a user is given a message "Some rules were not applied" with details telling them that they pressed the cancel button. It is a very odd "Feature" and can be very confusing for end users who will likely think they have done something wrong. It is also annoying when handling the exception in code as you have to check the message content to tell if the user cancelled.
I would suggest that they give some thought to imporving this both with/without code.
My first question to you... how on earth do I actually suggest this to microsoft? Does anyone know of an appropriate place? I have looke on connect and there are no office products on there at all?
My second... If anyone has dealt with the above before do you have suggestions on a good work around or perhaps you can tell me I have missed something and just being silly ;)
At present I submit using code an handle WebException then return if the message contains the cancelled message. Of course some may wish to do something if the users cancels. Personally I just don't want to show the user anything. I was considering writing something to handle all of the different messages in a more appopriate way but I can't even find a list of all the possible messages.
Most annoying one so far has been "Cannot add the form to the email as an attachment" a more or less useless message (gives no reasons). I found out eventually that it is caused when a form is submitted twice because the temporary files are not cleared so it can't save the form! This also seems like something of an issue so I wrote a method to first check the attachment name of the EmailSubmitConnection to see if it exists already. This way either you can delete it and send the form anyway or warn the user. It suprises me that this functionality does not exist already or the issue is not better documented.
At some point I may write a blog post surrounding this with what code I have written already. (I made a nice library of validation functions and helpers etc which I would like to share).
If any one has any comments or suggestions I would very much like to hear them.
Sorry for the long post ;p
Best regards