November Happy Hour will be moved to Thursday December 5th.

XForm e.FormData.ChannelOptions always equal to ChannelOptions.None

Vote:
 

I'm trying to intercept any XForm email to add my own formatting. I have a test form created and a button to trigger saving to the DB and send an email. The following event does fire, but e.FormData.ChannelOptions is always equal to ChannelOptions.None. I can never trap the XForm from sending the email.

private void OnBeforeSubmitPostedData(object sender, XFormDataEventArgs e)

{

            //***********************************//

            //*** Result from sending         ***//

            //***********************************//

            //ChannelOptions.None = 0, Nothing happens.

            //ChannelOptions.Database = 1, Save to database.

            //ChannelOptions.Email = 2, Send e-mail.

            //ChannelOptions.CustomUrl = 4, Post the data to a different Web page.

 

            if ((e.FormData.ChannelOptions & ChannelOptions.Email) == ChannelOptions.Email)

            {

                //Remove the option to send email directly from the XForm

                e.FormData.ChannelOptions &= ~ChannelOptions.Email;

 

                //***********************************//

                //*** Send e-mail to this address ***//

                //***********************************//

                string emailAdressTo = e.FormData.MailTo;

 

                //***********************************//

                //*** E-mail address of sender    ***//

                //***********************************//

                string emailAdressFrom = e.FormData.MailFrom;

 

                //***********************************//

                //*** E-mail subject              ***//

                //***********************************//

                string messageSubject = e.FormData.MailSubject;

 

                System.Collections.Specialized.NameValueCollection formValueCollection = e.FormData.GetValues();

                mailer = new Mailers();

                var message = mailer.XFormEmail(emailAddressTo: emailAdressTo, messageSubject: messageSubject, messageFields: formValueCollection);

                message.Send();

            }

        }

#84428
Apr 01, 2014 23:22
Vote:
 

I think I found the issue. We have a CaptchaValidator on a partial view that is attached to our XForm. This Post Action Result is basically eating the XFormDataEventArgs on the Before and After post data events. Not sure how to get around this.

#84506
Edited, Apr 02, 2014 16:55
Vote:
 

More digging and it's not the captcha. It's the Post Action in general.

#84513
Apr 02, 2014 18:15
Vote:
 

Hi Eric,

How did you get around this issue?

#90804
Sep 18, 2014 11:30
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.