DataAdapters syntax - InfoPath Dev
in

InfoPath Dev

DataAdapters syntax

Last post 07-18-2008 04:11 PM by Hilary Stoupa. 7 replies.
Page 1 of 1 (8 items)
Sort Posts: Previous Next
  • 07-17-2008 10:23 AM

    DataAdapters syntax

    Need help in using the the XDocument.DataAdapters using VB.net

     Tried the following but keep getting errors.

    Dim oEmail = XDocument

    Dim xDoc = XDocument 

    oEmail = xDoc.DataAdapters("Email Submit")

    The error I get is "Object reference not set to an instance of an object."

    I do have a data connection called Email Submit.

     
    Trying to email my form using code.  Samples would help

     

    Mike
     

  • 07-18-2008 05:36 AM In reply to

    <p>

    Please perform the "Type Casting" on (xDoc.DataAdapters("Email Submit")) then your problem will get solved.I can help you by writing the code only but sorry i dont have better knowledge on VB.net code. But i can give clear idea on what it is in C#.

    EmailAdapter oEmail =  (EmailAdapter)xDoc.DataAdapters("Email Submit");

    </p>

    Chandrakanth/GGKTech
  • 07-18-2008 09:51 AM In reply to

     Still does not work. and Microsoft's samples are lame.  For example from their page.

    Visual Basic(Usage)
    Dim instance as EmailAdapter
    Dim value as String

    value = instance.Subject
    instance.Subject = value

     Strange looking.

     

    Other sample I found as an example: Dim oEmail As EmailAdapter = DirectCast(xDoc.DataAdapters("Email Submit"), EmailAdapter)  and got "Object reference not set to an instance of an object error"

     

    I am just trying to send an email using code.  Can it be that difficult in VB?  I have been working on this for three days.  This is frustrating.  There are no good samples.  All the samples I have seen do not work are are incomplete.  People have a tendency to give samples and they assume you are an expert in the code, so many of the samples don't make sense.  Or when I try to use them, it seems incomplete.

     Thanks for your help anyway.

     

    Mike

     

     



  • 07-18-2008 12:24 PM In reply to

    Hi--

    Is there a reason you've set up a data connection to submit via email if you wish to submit using code? I'm just wondering -- did you have changes you wanted to make outside of the capabilities of the built-in email submit? If so, what are they? What version of IP are you using?

    Hilary Stoupa

  • 07-18-2008 01:40 PM In reply to

     Basically, what I am doing is to submit the form, not using code, to a SharePoint List, which I am doing now with success.  What I need to do is to email a confirmation email to a person requesting SharePoint training.  I can do that using the current data connection.  The problem is that the "To" field in the data connection sometimes uses the person's email address as  [email protected] and somtimes the person's email address is [email protected].  Big company and there are many instances that a person might have the same first and last name.  Also, in the body of the field, I cannot insert any variables.  The body has to be all text.  Well, I need to add the date of the SharePoint Training Class.  I have done that in the subject, but would want to add it in the body.

    When you way "What version of IP are you using?", what is that? 

     I am doing all this in VB.net and all the samples out there do not work.  They are either in JSript or C#.

    Mike 

  • 07-18-2008 01:46 PM In reply to

    I'm sorry, I shouldn't have abreviated. Are you using InfoPath 2003 or InfoPath 2007?

    Hilary Stoupa

  • 07-18-2008 03:13 PM In reply to

     IP 2007

     

    Mike 

  • 07-18-2008 04:11 PM In reply to

    Okay, using VB.NET and IP2007:

    ' Get the e-mail submit data connection configured for the form.
    Dim mySubmit As EmailSubmitConnection = DirectCast(Me.DataConnections("Main submit"), EmailSubmitConnection)

    ' Set To property to literal string value.
    mySubmit.To.SetStringValue("[email protected]")

    ' Submit form.
    mySubmit.Execute()

    This code came from here, (with a minor typo fix) and it compiles and runs. However -- several things of note. "Main submit" needs to be replaced with the name of your connection and there is no error handling. When the "pre-email" pop-up comes up in InfoPath, if I cancel sending the email, I'll get an error. The EmailSubmitConnection members are here and I do see Introduction, so you should be able to place a field there...

    Hopefully this will get you started -- if you need help getting the value of a form field, look into XPathNavigator (or search here) and let me know if you get stuck, okay?

    Hilary Stoupa

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