E-mail Submit Button - Code - Please can you assist with error? - InfoPath Dev
in

InfoPath Dev

E-mail Submit Button - Code - Please can you assist with error?

Last post 04-22-2010 12:45 PM by ncolyer. 4 replies.
Page 1 of 1 (5 items)
Sort Posts: Previous Next
  • 04-21-2010 11:02 AM

    E-mail Submit Button - Code - Please can you assist with error?

    I used the following code to create a submit button: 

     Public Sub btnSubmit_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)

    'get the value from the text field

    Dim interestingText As String = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:textField", NamespaceManager).Value

    'get the value from the date field

    ' Dim dateField As String = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:dateField", NamespaceManager).Value

    'get that email submit connection

    Dim emailSubmit As EmailSubmitConnection = Me.DataConnections("Email Submit")

    'set the introduction with a value from the form

    emailSubmit.Introduction = "This is my shiny new introduction with a date from my form: " + System.Environment.NewLine + "And an interesting value from a text field as well: " + interestingText

    'submit the form

    Me.Submit()

    End Sub

     

    I got this from http://www.infopathdev.com/blogs/hilary/archive/2008/08/24/so-you-want-to-send-an-email.aspx 

    I am getting the following error when I click the button.

    System.Security.SecurityException
    Request failed.
       at Microsoft.Office.InfoPath.MsxmlNavigator.IsValidNode(MsxmlNode test)
       at Microsoft.Office.InfoPath.MsxmlNavigator.MoveToFirstChild()
       at MS.Internal.Xml.XPath.XPathChildIterator.MoveNext()
       at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
       at MS.Internal.Xml.XPath.ChildrenQuery.Advance()
       at MS.Internal.Xml.XPath.XPathSelectionIterator.MoveNext()
       at System.Xml.XPath.XPathNavigator.SelectSingleNode(XPathExpression expression)
       at System.Xml.XPath.XPathNavigator.SelectSingleNode(String xpath, IXmlNamespaceResolver resolver)
       at WindowsServerProvisioningChecklist.FormCode.btnSubmit_Clicked(Object sender, ClickedEventArgs e)
       at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
       at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

  • 04-21-2010 07:46 PM In reply to

    Re: E-mail Submit Button - Code - Please can you assist with error?

     This looks like an error that occurs on certain MS office setups and is caused by a certain security patch:

    http://social.msdn.microsoft.com/Forums/en/sharepointinfopath/thread/b391b24b-2d2f-4bf0-b764-bab4654d2520

    the fix is to install MS Office 2007 SP2:

    http://www.microsoft.com/downloads/details.aspx?FamilyID=b444bf18-79ea-46c6-8a81-9db49b4ab6e5&displaylang=en

     
    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 04-22-2010 07:42 AM In reply to

    Re: E-mail Submit Button - Code - Please can you assist with error?

    It turns out I already had SP2 installed.

     After restarting my machine today though I'm getting a different error now when I test it from the preview.

    System.Collections.Generic.KeyNotFoundException
    The given key was not present in the dictionary.
       at System.ThrowHelper.ThrowKeyNotFoundException()
       at System.Collections.Generic.Dictionary`2.get_Item(TKey key)
       at Microsoft.Office.InfoPath.Internal.DataConnectionsHost.get_Item(String name)
       at WindowsServerProvisioningChecklist.FormCode.btnSubmit_Clicked(Object sender, ClickedEventArgs e)
       at Microsoft.Office.InfoPath.Internal.ButtonEventHost.OnButtonClick(DocActionEvent pEvent)
       at Microsoft.Office.Interop.InfoPath.SemiTrust._ButtonEventSink_SinkHelper.OnClick(DocActionEvent pEvent)

    Thank you again for your help.

     

  • 04-22-2010 07:54 AM In reply to

    Re: E-mail Submit Button - Code - Please can you assist with error?

    Ok I found out this was because my e-mail submit was labelled wrong. Should have been "SubmitForm".

     I have another question now. Is it possible for this button to submit the data in the body but not send the entire form with it as well? I just want it to send an e-mail with data in the body of the message if that is possible?

     Thanks again,

     Nick

  • 04-22-2010 12:45 PM In reply to

    Re: E-mail Submit Button - Code - Please can you assist with error?

     I managed to complete my code but it seems like the introduction part of the e-mail is limited...

     Is there anyway I can submit using the body of the e-mail instead? Here is my code after working through all my fields.

      Public Sub btnSubmit_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)
                'Define values from fields in Infopath
                Dim EngineerName As String = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:TB-EngineerName", NamespaceManager).Value
                Dim ServerName As String = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:TB-ServerName", NamespaceManager).Value
                Dim IPAddress As String = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:TB-PrimaryIP", NamespaceManager).Value
                Dim OS As String = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:DDB-OperatingSystem", NamespaceManager).Value
                Dim VMCreationDate As String = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:Date-Date", NamespaceManager).Value
                Dim FunctionalOwner As String = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:CMDBFunctionalOwner", NamespaceManager).Value
                Dim TechnicalOwner As String = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:DD-CMDBTechnicalOwner", NamespaceManager).Value
                Dim Environment As String = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:DD-CMDBEnvironment", NamespaceManager).Value
                Dim ImpactsRevenue As String = MainDataSource.CreateNavigator().SelectSingleNode("/my:myFields/my:DD-CMDBRevnue", NamespaceManager).Value

                'get that email submit connection
                Dim emailSubmit As EmailSubmitConnection = Me.DataConnections("SubmitForm")

                'set the introduction with a value from the form


                emailSubmit.Introduction = "%TYPE=R" + System.Environment.NewLine + _
                                            "%Summary=Windows Server Team - CI Creation Request for " + ServerName + System.Environment.NewLine + _
                                             "%Description= " + EngineerName + " is requesting a new CI be created for " + ServerName + " with IP Address " + IPAddress + System.Environment.NewLine + _
                                             "Details as follows:" + System.Environment.NewLine + _
                                            "Server Name: " + ServerName + _
                                            "IP Address " + IPAddress + _
                                            "Operating System " + ServerName + _
                                            "VM Creation Date " + VMCreationDate + _
                                            "Functional Owner " + FunctionalOwner + _
                                            "Technical Owner " + TechnicalOwner + _
                                            "Environment " + Environment + _
                                            "Impacts Revenue " + ImpactsRevenue

                                     
                'submit the form
                Me.Submit()
            End Sub

Page 1 of 1 (5 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.