Type: NullReferenceException, Exception Message: Object reference not set to an instance of an object - InfoPath Dev
in

InfoPath Dev

Type: NullReferenceException, Exception Message: Object reference not set to an instance of an object

Last post 03-03-2011 11:09 AM by g21cincy. 0 replies.
Page 1 of 1 (1 items)
Sort Posts: Previous Next
  • 03-03-2011 11:09 AM

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

    Type: NullReferenceException, Exception Message: Object reference not set to an instance of an object

    Locked Reply Contact

    Hello,

     I'm getting this error when trying to send an email out. Below is the code I'm using. I'm taking the data from a repeating table from each row where the "Add Trainee" checkbox is checked and sending  separate email(s) out to the RequestorEmail field(s) to let them know their request has been filled. Any help would be greatly appreciated

    Private Sub SendEmailToRequestor(ByVal GoToPacketSelection As Boolean)

    Dim Nav As XPathNavigator = Me.DataSources("Training Classes").CreateNavigator()

    Dim rows As XPathNodeIterator = Nav.Select("/dfs:myFields/dfs:dataFields/d:tblTrainingClasses", NamespaceManager)

    Dim iCounter As Integer = 1While rows.MoveNext()

     

    If GetValue("/dfs:myFields/dfs:dataFields/d:tblTrainingClasses[" & iCounter & "]/@AddTrainee", Nav) = "yes" Then

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

    Dim RequestorEmail As String = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:tblTrainingClasses[" & iCounter & "]/@RequestorEmail", NamespaceManager).Value

    Dim TraineeName As String = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:tblTrainingClasses[" & iCounter & "]/@NameOfTrainee", NamespaceManager).Value

    Dim Priority As String = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:tblTrainingClasses[" & iCounter & "]/@Priority", NamespaceManager).Value

    Dim EduationalCategory As String = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:tblTrainingClasses[" & iCounter & "]/@EduationalCategory", NamespaceManager).Value

    Dim Department As String = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:dataFields/d:tblTrainingClasses[" & iCounter & "]/@Department", NamespaceManager).Value

    Dim ClassName As String = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:queryFields/q:tblTrainingClasses/@ClassQuery", NamespaceManager).Value

    Dim DateEnrolled As Date = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:queryFields/q:tblTrainingClasses/@TimeQuery", NamespaceManager).Value

    Dim TimeEnrolled As String = MainDataSource.CreateNavigator().SelectSingleNode("/dfs:myFields/dfs:queryFields/q:tblTrainingClasses/@TimeQuery", NamespaceManager).Value

    Dim fromAddress As MailAddress = New MailAddress("[email protected]")

    Dim toAddress As MailAddress = New MailAddress(RequestorEmail)

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

    Select Case RequestorEmail

    Case Is = "[email protected]"

    RequestorName = "name"

    Case Is = "[email protected]"

    RequestorName = "name1"

    Case Is = "[email protected]"

    RequestorName = "name2"

    End Select

     

    msgmail.Subject = "MRSI Training form Enroll Request Fulfilled"

    msgmail.Body = RequestorName + "," + System.Environment.NewLine + _

    " " + System.Environment.NewLine + _

    "An enroll request that you submitted has been fulfilled with the following information:" + System.Environment.NewLine + _

    " " + System.Environment.NewLine + _

    "Trainee Name: " + TraineeName + System.Environment.NewLine + _

    "Priority: " + Priority + System.Environment.NewLine + _

    "Educational Category: " + EduationalCategory + System.Environment.NewLine + _

    "Department: " + Department + System.Environment.NewLine + _

    "Class: " + ClassName + System.Environment.NewLine + _ "Date: " + DateEnrolled + System.Environment.NewLine + _

    "Time: " + TimeEnrolled + " "

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

    client.Credentials = New System.Net.NetworkCredential("username", "password")

    client.Send(msgmail)

    End If

    iCounter += 1

    End While

    End Sub

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