Send Reports With List & Label as Email

Introduction

To activate the automatic e-mail dispatch of the report after the successful export, proceed as follows.

Implementation

For this purpose the option Export.SendAsMail must be activated with the value “1”. To see or show the email again before sending, the option Export.Mail.ShowDialog can be set to the value “1”. Further adjustable options such as the subject, the recipient address(es), the message text, the signature, the protocol to be used for sending, e.g. SMTP, XMAPI or Simple MAPI, the format of the message text and others can be found in the Programmer’s Manual under Setting Mail Parameters by Code.

Send Report as Attachment

The exported report (e.g. PDF) is then always attached to the email as standard. Optionally, additional files can be added via Export.Mail.AttachmentList.

Embed Report in Email Message Text

Often a report is prepared in such a way that it contains all important information to be able to use it directly 1:1 as an email message text. This is of course also possible with List & Label, but requires a few important points:

  • XHTML or HTML must be used as export format for the report. The format can either be defined by the user in the dialog and/or set with the function LlPrintSetOptionString.

For .NET (e.g. C#) (LlPrintSetOptionString)
Ll.Core.LlPrintSetOptionString(LlPrintOptionString.Export, "XHTML");

For API directly (for example C++) (LlPrintSetOptionString):
LlPrintSetOptionString(hJob, LL_PRNOPTSTR_EXPORT, "XHTML");

  • The protocol for email sending must be set to “XMAPI” or “SMTP” via the Export.Mail.Provider option.

  • In addition, the format of the message text must be set to “text/html” using the Export.Mail.SendResultAs option.

  • From version 25 on it is also useful to use infinite pages for the export.

Tips for Display Problems

If the report is embedded directly into the email message text, it is always in HTML format. However, it can happen that the HTML generated may not be displayed correctly in every email client used, such as Microsoft Outlook, Mozilla Thunderbird or various web mailers such as Gmail etc., as the HTML code is often interpreted very differently. The following tips can be helpful to influence the display of the HTML code in the email body a little:

  • When using the modern XHTML format as export format for the report, which also uses CSS, the option XHTML.UseAdvancedCSS can be deactivated with the value “0”.

  • You can also use the much simplified HTML format as export format for the report - see LlPrintSetOptionString:

For .NET (e.g. C#) (LlPrintSetOptionString):
Ll.Core.LlPrintSetOptionString(LlPrintOptionString.Export, "HTML");
Important: The print options must be set in the DefinePrintOptions event.

For API directly (e.g. C++) (LlPrintSetOptionString):
LlPrintSetOptionString(hJob, LL_PRNOPTSTR_EXPORT, "HTML");

Note for List & Label 26 and Higher

Starting with version 26, the simplified HTML format is no longer available as an export format by default and must first be activated separately, which can be implemented using LlSetOptionString.

For .NET (e.g. C#) (LlSetOptionString)

var availableFormats = LL.Core.LlGetOptionString(LlOptionString.Exports_Available);
LL.Core.LlSetOptionString(LlOptionString.Exports_Allowed, availableFormats + ";HTML");

For API directly (for example C++) (LlSetOptionString):

TCHAR aczAvailableFormats[256] = { 0 };
UINT nBuffSize = sizeof(aczAllowedFormats)/sizeof(TCHAR);
LlGetOptionString(hJob, LL_OPTIONSTR_EXPORTS_AVAILABLE, aczAvailableFormats, nBuffSize);
wcscat_s(aczAllowedFormats, L";HTML");
LlSetOptionString(hJob, LL_­OPTIONSTR_­EXPORTS_­ALLOWED, aczAvailableFormats, nBuffSize+5);

More Links for Sending Emails With List & Label

Sending E-Mail with .NET
Send Export Results via E-Mail