Setting Mail Parameters by Code

Similar to the other export options, the parameters for sending by email can also be set. In the project properties, the user can already specify some mail parameters such as sender, recipient or subject, which are automatically used. See the chapter Project Parameters for further details. A couple of other options can be set or read using LlXSetParameter(..."<exporter name>"...) / LlXGet­Parameter(..."<exporter name>"...). Note that the exporter name may be left empty to address all export modules.

Export.SendAsMail: Activates sending of export files via email. This option corresponds to the checkbox "Send exported files by email" for the end user.

Value

Meaning

0:

No mail will be sent

1:

The exported files are sent via the specified provider (see below)

Default:

0

 

Export.SendAsMailAvailable: Enables you to hide the respective checkbox in the dialog.

Value

Meaning

0:

Checkbox will be hidden

1:

Checkbox will be available

Default:

1

 

Export.Mail.Provider: This option can be used to switch the mail provider. All options apart from Simple MAPI need the CMMX29.DLL.

Value

Meaning

SMAPI

Simple MAPI

XMAPI

Extended MAPI

SMTP

SMTP

MSMAPI

Simple MAPI (using the default MAPI client)

GRAPH

Microsoft Graph API, e.g. for the Office365 Cloud

Hint: Requires optional modules. Please refer to the file Redist.txt in your List & Label installation directory.

Default

The default value depends on the system's or application's settings (see below)

 

If the DLL cannot be found, the mail will be sent using system Simple MAPI (MSMAPI).

The provider is selected by either setting it explicitly using this option or letting the user choose in the LsMailConfigurationDialog().

List & Label first of all tries to retrieve the application-specific mail settings from the registry. These can be set using LsMailConfigurationDialog(). If your application wants to support sending report results by email then you should provide the end-user a menu-item (or similiar) in which's handler you call LsMailConfigurationDialog() to enable the end-user to specify the mail settings. Note: Please set both export options Export.Mail.@Configuration.User and Export.Mail.@Configuration.Computer with the help of LlxSetParameter() to the identical value with which you called LsMailConfigurationDialog() to save the settings for mail sending individually in the registry.

Export.Mail.To: Recipient for the email.

Export.Mail.CC: CC- Recipient for the email.

Export.Mail.BCC: BCC- Recipient for the email.

Export.Mail.From: Sender of the email. Substitutes the sender's address (combination of "Export.Mail.SMTP.SenderName" and "Export.Mail.SMTP.SenderAddress") in the mail. However, "Export.Mail.SMTP.SenderAddress" will still be used for the SMTP protocol.

Export.Mail.ReplyTo: Target for reply email if different to "From" (SMTP only).

Export.Mail.Subject: Mail subject.

Export.Mail.HeaderEntry:Message-ID: Message-ID of the email.

Export.Mail.Body: Mail body text.

Export.Mail.Body:text/plain: Mail body text in plain text format. Identical to Export.Mail.Body.

Export.Mail.Body:text/html: Mail body text in HTML format (SMTP and XMAPI only). Optional, otherwise the mail will be sent with the text defined in Export.Mail.Body or Export.Mail.Body:text/plain.

Export.Mail.Body:application/RTF: Mail body text in RTF format (XMAPI only).

Export.Mail.SignatureName: The name of an Outlook signature or the path and file name (without file name extension!) of a signature file. Depending on body text type, the file name extension txt, rtf or htm will be appended.

Export.Mail.AttachmentList: Additional attachments (besides the export results) as tab-separated list ("\t", ASCII code 9).

Export.Mail.ShowDialog: Selection for sending the mail without any further user interaction.

Value

Meaning

0:

The mail is sent directly without any further user interaction (at least 1 TO recipient must be set). If no recipient is set the dialog will be shown.

1:

The standard "Send mail" dialog is displayed. The values passed are preset there.

Default:

0

 

Export.Mail.Format: Set the default for the file format selection dialog in the preview. Valid values are: "TIFF", "MULTITIFF", "LL", "XML", "XFDF", "XPS", "PDF", "JPEG", "PNG", "TTY:<emulation>", "EMF".

Export.Mail.SendResultAs: Allows the result of an HTML export to be sent directly as HTML mail text.

Value

Meaning

text/html

If SMTP, XMAPI or Microsoft Graph is chosen as mail provider, the export result is used as HTML content of the mail. All other mail providers will ignore this option.

empty

The HTML result is sent as attachment.

Default

Empty

 

Export.Mail.SignResult:

Value

Meaning

0

Email will not be signed.

1

Email will be signed.

Default

0

 

The SMTP provider offers a set of additional options. These generally do not need to be set explicitly, but should be set in the LsMailConfigurationDialog().

 

Export.Mail.SMTP.SocketTimeout: Socket timeout, in milliseconds, default 1000.

Export.Mail.SMTP.LogonName: Login name for the server, default: computer name (usually unimportant).

Export.Mail.SMTP.SecureConnection: Connection security.

Value

Meaning

-1

Automatic (use TLS when server supports it)

0

Turn TLS off (even when it is supported by the server)

1

Force SSL (Cancellation when server does not support SSL)

2

Force TLS (Cancellation when server does not support TLS)

Default

-1

 

Export.Mail.SMTP.ServerAddress: SMTP server IP address or URL

Export.Mail.SMTP.ServerPort: SMTP server port, default 25.

Export.Mail.SMTP.ServerUser: SMTP server user name (if necessary)

Export.Mail.SMTP.ServerPassword: SMTP server password (if necessary)

Export.Mail.SMTP.ProxyType: Proxy type (0=none, 1=Socks4, 2=Socks5)

Export.Mail.SMTP.ProxyAddress: Proxy IP address or URL

Export.Mail.SMTP.ProxyPort: Proxy port, default 1080

Export.Mail.SMTP.ProxyUser: Proxy user name (only Socks5)

Export.Mail.SMTP.ProxyPassword: Proxy password (only Socks5)

Export.Mail.SMTP.POPBeforeSMTP: Some SMTP server need a login via POP before SMTP connection (0=no POP connection will be established, 1= POP connection will be established)

Export.Mail.SMTP.SenderAddress: Mail sender's address (ex. xyz@abc.def) – is also used for the SMTP protocol

Export.Mail.SMTP.SenderName: Real sender's name

Export.Mail.SMTP.ReplyTo: Reply to address (optional)

Export.Mail.SMTP.OAuth2.BearerToken: Authentication token if the SMTP server supports authentication via OAuth2.

Export.Mail.POP3.SocketTimeout: Timeout for socket connection in ms, default: 10000

Export.Mail.POP3.SecureConnection: Connection security.

Value

Meaning

-1

Automatic (use TLS when server supports it)

0

Turn TLS off (even when it is supported by the server)

1

Force SSL (Cancellation when server does not support SSL)

2

Force TLS (Cancellation when server does not support TLS)

Default

-1

 

Export.Mail.POP3.SenderDomain: Login domain, default: computer name

Export.Mail.POP3.ServerPort: default: 110

Export.Mail.POP3.ServerAddress: URL/IP address of POP3 server, default: "localhost"

Export.Mail.POP3.ServerUser: user for authentication

Export.Mail.POP3.ServerPassword: password for authentication

Export.Mail.POP3.ProxyAddress: proxy server address

Export.Mail.POP3.ProxyPort: proxy server port, default 1080

Export.Mail.POP3.ProxyUser: proxy server user name

Export.Mail.POP3.ProxyPassword: proxy server password

Export.Mail.XMAPI.ServerUser: profile name for authentication

Export.Mail.XMAPI.SuppressLogonFailure: "0" / "1" show (no) dialog for login error

Export.Mail.XMAPI.DeleteAfterSend: "0" / "1" delete mail after sending

Export.Mail.Graph.AuthType: (Required) Authentication type.

Value

Meaning

0

Interactive. Based on all other parameters, a (user) specific token is generated with user interaction. The user needs appropriate rights to send emails.

1

Service. Based on Export.Mail.Graph.SecretClientKeyId and Export.Mail.Graph.SecretClientKeyValue and the other parameters, an (app)specific token is generated without user interaction. The app requires appropriate permissions to send emails on behalf of other users.

2

UserPassword. Based on Export.Mail.Graph.UserName and Export.Mail.Graph.UserPassword and the other parameters, a token is generated without user interaction. The user needs appropriate rights to send emails.

3

Token. The externally generated Export.Mail.Graph.BearerToken passed here is used. The token must contain the rights necessary for sending.

Default

3

 

Export.Mail.Graph.ClientId: (Required) The application ID assigned in Azure AD is required.

Export.Mail.Graph.TenantId: (Required) The directory id assigned to the application is required.

Export.Mail.Graph.Scope: (Optional) The access rights to be requested are required. Default: https://graph.microsoft.com/.default

Export.Mail.Graph.RedirectUri: (Optional) A redirect URI configured for the app is required. Default: http://localhost

Export.Mail.Graph.SecretClientKeyId: (Optional) This ID is only required for Ex-port.Mail.Graph.AuthType 1 (Service).

Export.Mail.Graph.SecretClientKeyValue: (Optional) This value matching Ex-port.Mail.Graph.SecretClientKeyId is only required for Export.Mail.Graph.AuthType 1 (Service).

Export.Mail.Graph.UserName: (Required) User name. Required for all authentication types (see Export.Mail.Graph.AuthType).

Export.Mail.Graph.UserObjectId: (Optional) This Id can be used for Ex-port.Mail.Graph.AuthType 0 (Interactive) as an alternative to Export.Mail.Graph.UserName.

Export.Mail.Graph.UserPassword: (Optional) The password to the user name is required for Export.Mail.Graph.AuthType 2 (UserPassword).

Export.Mail.Graph.BearerToken: (Optional) The externally generated BearerToken is required for Export.Mail.Graph.AuthType 3 (Token).

 

Example:

LlXSetParameter(hJob,LL_­LLX_­EXTENSIONTYPE_EXPORT,"","Export.SendAsMail", "1");

This automatically sends the export result as email to the recipient selected via Project > Settings. The globally selected mail settings will be used. If you want to offer a default to your user, this can be done quite simply:

LlSetDefaultProjectParameter(hJob,"LL.Mail.To", "EMAIL", 0);

This example assumes that your database contains a field called EMAIL. If you want to preset a specific address, please note that you need to use single quotes, as the passed parameter needs to be evaluated as the formula:

LlSetDefaultProjectParameter(hJob,"LL.Mail.To", "'abc@xyz.de'", 0);