O'Reilly logo

Beginning InfoPath™ 2003 by F. Scott Barker

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

14.2. Sending a Form in an E-Mail

Another useful feature is to be able to send forms to other users via e-mail. While you can accomplish this using the menu choices, it is also more professional and convenient to be able to create code to accomplish the same thing.

To send a form using e-mail, you will need to perform a couple of steps: First, you need to create a data connection for your form, but in this case it will be used for sending e-mail instead of submitting and retrieving data to and from a database. You can see the Data Connection Wizard used for setting up the data connection in Figure 14-7.

Figure 14.7. Figure 14-7

Although you have to specify someone for the To field when creating the data connection, you can change all the properties using code at runtime.

The next step is to create the form you want to send. Finally, you have to write the necessary code, added to a command button on the form. The code created will use a DataAdapter from the DataAdapters collection off the XDocument object. You can see the line of code here:

var objEmail = XDocument.DataAdapters("Submit");

Because you set the data adapter up to work with e-mail, InfoPath knows how to use it. The following table contains some of the properties for the Email Adapter:

PropertyDescription
AttachmentFileNameSets or returns the name of the attachment that will be made of the for.
BCCBCC recipient
CCCC recipient ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required