Message-ID: <1093978836.2417.1710836241451.JavaMail.web05$@web05> Subject: Exported From Confluence MIME-Version: 1.0 Content-Type: multipart/related; boundary="----=_Part_2416_1161139875.1710836241451" ------=_Part_2416_1161139875.1710836241451 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Content-Location: file:///C:/exported.html SharePointIntegration.SetMailMerge(WordTemplate, Microsoft.Share= Point.SPList, Int32)

SharePointIntegration.SetMailMerge(WordTemplate, Microsoft.SharePoi= nt.SPList, Int32)

Introduced in build 4.1.0.1379

=20

Description

=20

Sets the MailMerge's data source to a SharePoint View. A MailMerge by de= fault treats the page content as a repeat block, repeating the page content= for each row unless NEXT fields are used. If the WordTemplate.EnableNEXTFields property is= set to true, the NEXT field can also be used to indicate that the next row= of data should be inserted instead of the current row at the next occurenc= e of the merge fields.

=20
C#
=20
public void SetMailMerge(this WordTemplate template, Microsoft.SharePoint.S=
PList list, int maxRows)
=20
=20
vb.net
=20
Public Sub SetMailMerge(ByVal template As WordTemplate, ByVal list As Micro=
soft.SharePoint.SPList, ByVal maxRows As Integer)
=20
=20

Parameters

=20
template
Current WordTemplate that is call= ing SetMailMerge=20
list
A SharePoint List to use as a data source= .=20
maxRows
Specifies the maximum number of row= s to import from the data source. To import the maximum rows available, use= the constant=20 WordTemplat= e.ALL_ROWS.=20

Exceptions

=20
ArgumentNullException
=20 Save will t= hrow this exception if=20 null (C#) or=20 Nothing (VB.NET) is passed to the method.=20
ArgumentException
=20

Remarks

=20

You can call SetMailMerge once for each instance of WordTemplate. If you are using the Exce= l 2003 binary template file type (.xls/.xlt), you can call SetMailMerge or = SetRepeatBlock, but not both.

=20

Additionally, only the page content is repeated for each row, not the en= tire page itself. If you wish to have the page itself repeat for each row, = you will need to remember to place a page break at the bottom of the page.<= /p>=20

Merge Fields for using the SetMailMerge method must not specify a data s= ource =E2=80=93 the data source is implied, and using a data source name wi= ll cause WordTemplate to throw an error. Valid merge field formats for use = with SetDataSource include field names («fieldname») and field ordinals («#1»).

=20
=20 Icon=20
=20

This is an extension method for the WordTemplate object to be used for b= inding SharePoint data to applications from within SharePoint. To use this = method, you must add a reference to SoftArtisans.OfficeWriter.WordWriter.Sh= arePointIntegration.dll

=20
=20
=20

Examples

=20
C#
=20

          //--- Set the mail merge
          //--- The data source is the SharePoint List myList
          //--- MaxRows is set to ALL_ROWS, which allows all rows to be imp=
orted
          wt.SetMailMerge(myList, WordTemplate.ALL_ROWS);
          wt.Process();
        
=20
=20
vb.net
=20
          '--- Set the mail merge
          '--- The data source is the SharePoint List myList
          '--- MaxRows is set to ALL_ROWS, which allows all rows to be impo=
rted
          wt.SetMailMerge(myList, WordTemplate.ALL_ROWS)
          wt.Process()
        
=20
------=_Part_2416_1161139875.1710836241451--