Sending a non-active view via email? - InfoPath Dev
in

InfoPath Dev

Use our Google Custom Search for best site search results.

Sending a non-active view via email?

Last post 06-06-2016 08:06 AM by iLoveData. 22 replies.
Page 2 of 2 (23 items) < Previous 1 2
Sort Posts: Previous Next
  • 05-27-2013 12:35 PM In reply to

    Re: Sending a non-active view via email?

    Hi Hillary,

    I came across your post a few weeks ago thanks to Ernesto Machado, but I wanted to do some of my own troubleshooting to find out what is causing my form data to auto-stretch in the body of an email message after submitting it via an email data connection.

    What I discovered is that ( without the use of sections, buttons and rules) placing the following input objects ( Date Picker, Date & Time Picker and Multiple Selection Box ) in your form are not translated properly when the form is submitted. I also tried statically setting all column and input object widths but still no success. Any other input objects that I used, the form data in the body of the email is fine.

    Strange though, when I uploaded my form to my server for the first time without any data connections defined (using Date Pickers), it gives the option to email the form for review. When it is received, it looks exactly as it should.

    So in your solution you mention the use of 2 sections. If I wanted the fill section and the email section to be the same how would I set that up?

    Also, I was able to set up a boolean field called isEmailing, but why is that necessary?

    I am a little unclear with this, if you could clarify your solution it would be greatly appreciated.

    Many Thanks.

  • 05-29-2013 07:14 AM In reply to

    • g21cincy
    • Top 150 Contributor
    • Joined on 10-20-2008
    • Cincinnati, OH
    • Posts 64

    Re: Sending a non-active view via email?

    Have you tried sending the email programmatically using code behind the view? That's how I usually send emails and formatting everything in HTML.

  • 05-29-2013 11:24 AM In reply to

    Re: Sending a non-active view via email?

    No I haven't. Everything in my web based form is functioning properly. When it's submitted using an email data connection, the form data that is received in the body of the email message is fine. 

    It is only when I add a date picker input object in the form when it causes the column where the object resides to autostretch after it is submitted. I ended up just replacing that with a date formated text field as a workaround. 

    Ideally, I would really like to find a solution that would allow me to use that object.

    I am presently trying to set up an non-active view to see if that will fix the formatting issue. 

    If I did want to format in HTML, where would I define that?

  • 05-29-2013 12:06 PM In reply to

    • g21cincy
    • Top 150 Contributor
    • Joined on 10-20-2008
    • Cincinnati, OH
    • Posts 64

    Re: Sending a non-active view via email?

    The following is the code that I use to send data via email from InfoPath browser forms.

     

    Dim Nav As XPathNavigator = Me.CreateNavigator()

    Dim EmailFrom As String = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/my:Email/my:EmailFrom", NamespaceManager).Value

    Dim SubjectOfMessage As String = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/my:Email/my:EmailSubject", NamespaceManager).Value

    Dim FullName As String = MainDataSource.CreateNavigator().SelectSingleNode("XPath/@FullName", NamespaceManager).Value

    Dim DateVariable As String = Date.Parse(MainDataSource.CreateNavigator().SelectSingleNode("XPath/@Date", NamespaceManager).Value)

    Dim fromAddress As MailAddress = New MailAddress(EmailFrom)
    Dim toAddress As MailAddress = New MailAddress("Name@somecompany.net")

    Dim msgmail As MailMessage = New MailMessage(fromAddress, toAddress)

    msgmail.To.Add("Name@somecompany.net")  'Additional email address to send email to

    msgmail.Subject = SubjectOfMessage + "Static text in subject line"

    msgmail.IsBodyHtml = True

    msgmail.Body = "<html><tr><td>Full Name:</td><td>" + FullName + "</td></tr>" + _
    "<tr><td>Date:</td><td>" + DateVariable + "</td></tr></html>"

     

    Dim client As SmtpClient = New SmtpClient("Email_Server")

    client.Credentials = New System.Net.NetworkCredential("UserName", "Password")
    client.Send(msgmail)

  • 05-30-2013 11:39 AM In reply to

    Re: Sending a non-active view via email?

    It will take me some time to set this up as I would have to define the HTML code in the body of the email. I will let you know how that goes. Thanks for the info.

  • 06-04-2013 09:09 AM In reply to

    • Joy_T
    • Not Ranked
    • Joined on 10-25-2012
    • Posts 20

    Re: Sending a non-active view via email?

    I have been able to finally keep the formatting correct for an email-submitted browser form!  See fun and exciting instructions below, with explanations in parentheses.

    1. Ensure that the width of every field in the form is a numeric pixel width and not a percentage (reason: percentage widths will not format properly when emailed)

    2. Each line of the form has to be created as a separate table (reason: when the browser form is submitted via email, it does not like merged cells and will completely mess up the formatting)

    3. Any date-picker contained in the form has to be recreated separately in its own section as just the data for the email submission, using the guidelines from earlier in this conversation post (regarding section hiding and such).  This will thereby make sure that the date-picker field itself will not be part of the email submission (since the date picker field will also completely mess up the formatting)

    To elaborate, in one instance I have one field that is a date picker, called "Date"; this field with title are now in their own section, which I have called "DatePicker_Section".

    I have created a second section directly beneath this, containing a text field called "DateValue", in a section called "DateValue_Section".  The "DateValue" field is set as a locked Date formatted text field (and not a date picker field), with the formula set to equal the value of the "Date" field.

    I then used the sections and rules outlined earlier in this handy post from Hilary Stoupa, setting it up so that the DatePicker_Section is visible when the form is being filled out, but that the DateValue_Section is visible when the form is submitted via email.

     

    Following the many painstaking hours it took to make all these changes, my form is now properly submitting and emailing without messing up any of the formatting. :)

  • 06-05-2013 02:19 PM In reply to

    Re: Sending a non-active view via email?

    YAY! I really did cheer...people in the office are looking at me strangely now. :)

    No matter, as I have finally got my IP 2010 form functional now! I will pass on my findings, which may prove to be interesting.

    I have a lot of information that needs to be populated on my form, so I spent time formatting it so it could be just submitted as is, without having to recreate another view.

    1. Right click on the background, select View Properties and under the General tab/Layout Settings set a custom layout width.

    2. Statically set all object widths with pixels not percentage as Joy_T described.

    3. I have 1 table which includes all of my form content, and I created a new section below it. Cut and pasted the table into the section.

    4. Copy and paste the section. Now I have 2 sections with my form displaying twice. ( Note that not all controls store duplicate data, specifically the Option Button object. )

    5. For the Date Picker object and for the Option Buttons, I replaced those in the 2nd section with text fields which pull values from the 1st section.

    6. Using Hilary's solution, I created a boolean field called IsEmailing and set it to FALSE. (note the default capitalization of FALSE and TRUE)

    7. Select Section 1 and create a Formatting Rule. Condition: IsEmailing is equal to TRUE. Rule Type: Formatting, select Hide this control.

    8. Select Section 2 and create a Formatting Rule. Condition: Is Emailing is equal to FALSE. Rule Type: Formatting, select Hide this control.

    9. Under the Data tab on the toolbar, select Submit Options and select 'Perform custom action using Rules. Now select Form Submit in the Rules grouping

    10. Now to create 3 action rules... Rule 1 - Condition: IsEmailing = FALSE, Rule Type: Action, Run these actions: Set a field's value IsEmailing=true (lower caps)

    11. Rule 2 - Condition: None, Rule Type: Action, Rune these actions: Submit using Email Data Connection

    12. Rule 3 - Condition: IsEmailing = TRUE, Rule Type: Action, Run these actions: Set a field's value IsEmailing=false (lower caps)

    My hang up was with the errors that it was generating after trying to submit it via preview. What I discovered is that when setting the field values for IsEmailing, I used TRUE instead of true and FALSE instead of false....arg.

    I do have multiple merged cells in my form, I haven't seen a need to create a separate table for each line...yet.

    Considering the large numbers of forms I have to generate to be accessible to users in a SharePoint environment, I needed to find a workaround in IP.

    Thanks to ErnestoM for pointing me in the right direction, Joy_T and g21cincy for you responses and 3 cheers for Hilary!
  • 06-06-2016 08:06 AM In reply to

    • iLoveData
    • Not Ranked
      Female
    • Joined on 06-06-2016
    • Richmond, VA
    • Posts 6

    Re: Sending a non-active view via email?

    You have changed my world with this response. I was originally looking for a way to hide the submit button on a submitted form but this is a much better solution and allows for a read only version on submit. Thank you so much for sharing.
    Data, data and more data. Oh, and did I mention data?
Page 2 of 2 (23 items) < Previous 1 2
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.