The Mail module is used to define a mailbox and set it up correctly. Mail can be opened using the tree menu of the module Communication / Mail / Email accounts settings.
Email accounts settings
To be able to use mail in scripts, it is necessary to set the connection parameters to the mailboxes using the Email accounts settings function.
Email boxes tab
The Email boxes tab shows a list of all defined accounts of the logged-in user. When Email accounts settings is opened, K2 checks whether any accounts have already been created, and if it finds none, it generates new ones. For each user, two mailboxes are created after logging in to IS K2 - one internal and one external. K2 distinguishes between external and internal accounts based on the set e-mail address:
- Internal account - the address of the internal e-mail account either has no domain (no @ and nothing after it) or has the domain @mail.k2.
- External account - the external account is generated with the e-mail address entered on the User card. If no address is filled in there, an e-mail address in the format "user abbreviation@mail.external.k2" is generated. The user can create any number of external mailboxes and accounts.
When saving Email accounts settings, IS K2 checks:
- the number of internal accounts - there can be only one internal account. If there are more, the user is notified of this. The system asks whether to continue saving. The user thus has the option to return to editing without the account being deleted.
- e-mail of external accounts - it is checked whether the external accounts contain an e-mail address ending with @mail.external.k2. If it finds any, it notifies the user, similarly to the previous point. Such an account is not necessarily wrong. For example, if the user uses Outlook, the e-mail address is taken from Outlook and not from K2 when sending. Setting the address is redundant in such a case and in K2 serves rather for clarity.
Note: The internal mailbox is no longer used in the standard and remains here only for historical reasons, as the internal mailbox may be used in special scripts.
Warning: Sending e-mails via the new Outlook is not supported.

Picture: Email accounts settings form - Email boxes tab
Signatures tab
The Signatures tab contains a list of all defined signatures, which are then set on individual accounts.

Picture: Email accounts settings form - Signatures tab
Description of functions in the ribbon
Global proxy |
The global proxy setting allows the user to share proxy values between different accounts, which eliminates the need to repeatedly enter the same data for each account. |
Admin view |
The action is available only to a user with the Service operations right. The administrator can view and change the email account settings of all K2 users. |
Bulk settings |
This action is available only to users with the Service operations right. It is used for bulk setting of the protocols used for multiple email accounts. First, the administrator selects the accounts to be changed, and then fills in the values for receiving and sending mail. These values are then written to all the selected accounts. Names and passwords remain unchanged. |
The setup of an email account depends on its intended purpose. Apart from setting up the mail servers, the operator must focus primarily on the following during setup:
- The operating system on which K2 is run.
- The version of the default mail client (Outlook 2003, Outlook 2007, Thunderbird, etc.).
- The database on which IS K2 runs (MS SQL).
Mailbox settings
Press the Enter key or double-click to open the settings of the given e-mail box.
Basic data tab

Picture: Mailbox settings form - Basic data tab
Description of fields:
Name of account |
Field for any account name. |
Your name |
The name that will be used when sending messages from this account. |
E-mail address |
Field for entering the e-mail address. |
Address for replies |
Address for sending replies. An empty value here means replying to the same address. Multiple addresses separated by commas can be entered in the field. |
Default mailbox for sending |
This option can be checked for only one mailbox of all those defined. The flag must be set on the mailbox that the user will use to send e-mails from a script, e.g. Export to email. |
Use to receive and send |
If the user also wants to receive mail in their mailbox, this option must be checked. |
Save copy of sent message |
If the field is checked, a copy of the sent mail is saved in the Sent folder. |
Display |
A mailbox with this setting is displayed in the list of all accounts in the Mail book. |
Hidden copy to myself |
If this field is checked, the sender's address is always automatically added to the blind copy of an e-mail sent via this mailbox. The user can thus be informed about all sent e-mails. |
Interval to check for new messages |
Interval for checking for new messages. It is specified in minutes. |
Post client |
Selection of the mail client for editing messages. |
Format for creating reports |
Default text format for creating new messages. |
Signature |
Field for selecting a signature. |
OAuth2 |
The OAuth2 authentication setting under this button allows its values to be shared for both Post sending and Post receipt, which means that the user does not have to enter these values repeatedly for each setting separately. On the Post sending / Post receipt tab, if the OAuth2 authorization protocol is selected, it is sufficient to check the "Superior" option. |
Test connection |
Button for testing the mailbox settings. A message about the connection status is displayed. |
Post sending tab
On the Post sending tab, we choose the method of sending mail from this account. After selecting the protocol, other relevant fields required for the setup are displayed.
Individual protocols may require authentication using a name and password or using the OAuth2 protocol. For the procedure to set up OAuth2, see Setting up a Google account in IS K2 and Microsoft authorization. If the OAuth2 authorization protocol is selected, checking the "Superior" option allows the OAuth2 authentication settings to be taken over from the Basic data tab.

Picture: Mailbox settings form - Post sending tab
MAPI
For MAPI to work, the following 2 conditions must be met:
- The e-mail client must be compiled for the same architecture as the K2 client. If the e-mail client is opened from the 32-bit desktop client, the e-mail client must also be 32-bit. If e-mails are sent from 64-bit WebNative, the e-mail client must be 64-bit.
- The registry must contain the value HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Windows Messaging Subsystem MAPI = 1. Again, this depends on whether it is a 32-bit or 64-bit client, as each architecture has its own values. We recommend setting both the 32-bit and the 64-bit registry.

Post receipt tab
The Post receipt tab is used to define the way in which the user will receive mail in this account. The user selects the relevant protocol here. After selecting the protocol, other relevant fields required for the setup are displayed. The same conditions apply to authentication as for Post sending.

Picture: Mailbox settings form - Post receipt tab
Settings tab
On the Settings tab, we set the proxy server. If the user has multiple email accounts and does not want to repeatedly enter the same values for each account, they can simply check the "Use global settings" option and set the values for the proxy used via the Global proxy function.
In the Confirmation section, the user can set a request for a read receipt of the e-mail. The other party may or may not comply with this request.

Picture: Mailbox settings form - Settings tab
Setting up a Google account in IS K2
If the user wants to use their Google account within a mailbox in IS K2 and use this account for sending e-mails, they must set up its authorization. This process involves several steps.
It is no longer possible to use so-called basic authentication (login using a user name and password) to log in to a Google account from third-party applications. For these purposes, it is necessary to use the so-called OAuth2 protocol.
The entire authentication process consists of creating a project for a specific Google account within the Google Cloud Platform console, which is available at https://console.cloud.google.com/.
Subsequently, within this project, it is necessary to create an application for the OAuth2 authorization protocol and create Credentials (a verification client) of the OAuth2 protocol.
The last step is to enter the data of this project into IS K2.
Creating a Google Cloud Platform project
Within their Google account, the user who wants to send e-mails from IS K2 must have a project created in the Google Cloud Platform console. The URL address of this console is https://console.cloud.google.com/. A prerequisite is that the user is logged in to the given Google account in the web browser.

Picture: Home screen of the Google Cloud Platform console
A new project on Google Cloud Platform is created by clicking Select a project and then the NEW PROJECT option.

Picture: Creating a new project
On the next screen, set the project name in the Project name field.

Picture: Entering the project name
Confirm the creation of the project with the CREATE button.
Creating an application for the OAuth2 protocol
Within the created project in Google Cloud Platform, it is further necessary to set up an application for the OAuth2 authorization protocol.
The project must be selected in the Google Cloud Platform console. After creation, it is set here. However, if it is not currently set, select it using the button with the project name.

Picture: Button for selecting projects
A list of all projects of the Google account in the console is always displayed. Select the required project from this list.
Using the
icon, display all available project options and select APIs & Services here.

Picture: Displaying the APIs & Services section
In the APIs & Services section, then click the OAuth consent screen option. Here, create an application for verification with the OAuth2 protocol.

Picture: Creating an application for OAuth2
Here, first select the External option and confirm the choice with the CREATE button.
On the next screen, enter the name of the application in the App name field and enter a contact e-mail in the User support email field. As a rule, we enter the e-mail address of the Google account whose project in Google Cloud Platform we are working with. Another mandatory field is Developer contact information at the bottom of the screen. An e-mail address must be entered here as well.

Picture: Other settings of the application for OAuth2
The settings can then be confirmed with the SAVE AND CONTINUE button.
The next step of creating "Scopes" can be skipped by pressing the SAVE AND CONTINUE button again.
Next, we get to the screen where it is necessary to set the users of the application for the OAuth2 protocol.

Picture: Setting users for the application
Here, the user of the specific Google account for which this project is created and from which e-mails will be sent from IS K2 must be entered. Add the user here using the ADD USERS button. Then fill in the e-mail address and confirm adding the user with the ADD button. After adding the user, confirm the whole screen again with the SAVE AND CONTINUE button. Then the last screen, Summary, is displayed with an overview of the application data for the OAuth2 protocol.
The application is created and we can click the BACK TO DASHBOARD button here.

Picture: Completing the creation of the application
The next step for the application for the OAuth2 protocol to work is setting up the so-called Credentials (verification). This is essentially creating an OAuth client for verification. In the project, click the Credentials section and then the + CREATE CREDENTIALS button.

Picture: Creating an OAuth client
In the context menu, then select the OAuth client ID option.

Picture: Context menu for selecting the verification type
A screen is displayed where you select Desktop app in the Application type field. This is because it is an application for the desktop version of IS K2.

Picture: Selecting the application type for verification
On the next screen, enter a name for identification within the console, and press the CREATE button to create the verification.

Picture: Confirmation for creating an OAuth client for verification
The verification client is created and a window is displayed containing two fields, Client ID and Client Secret. The keys from these fields are very important for setting up e-mail sending from IS K2 via a Google account.

Picture: Client ID and Client Secret for setup in IS K2.
Further settings for the correct functioning of e-mail sending must be made in IS K2.
Settings in IS K2
Further settings for sending e-mails from IS K2 via a Google account must be made directly in IS K2 in the Mail module. All data for the Google account is entered here in the settings of the given mailbox.
So if we want to set up a Google account here, it is first necessary to enter the e-mail address in the E-mail address field on the Basic data tab.

Picture: Settings on the Basic data tab
Next, on the Post sending tab, select the SMTP option. After selecting the SMTP protocol, further data required for sending e-mail via the SMTP protocol is displayed. Enter the Server address (smtp.gmail.com), Port (587) and Secure connection (Explicit TLS).

Picture: Settings on the Post sending tab
Instead of verifying the account using a name and password, we must set identity verification using the OAuth2 protocol here. After selecting the OAuth2 authorization protocol, all the data required to set up this protocol is displayed.

Picture: Setting up the OAuth2 protocol in IS K2
Description of fields:
Client ID |
Here it is necessary to enter the Client ID obtained by creating a client for verification of the OAuth2 protocol (OAuth client) within Google Cloud Platform. |
Client Secret |
Here it is necessary to enter the Client Secret obtained by creating a client for verification of the OAuth2 protocol (OAuth client) within Google Cloud Platform. |
Authorization URI |
The field is filled in automatically with the value intended for a Google account. The program fills it in automatically if it identifies a Google account in the E-mail address field on the General tab. The identification is based on the "*.gmail.com" suffix. If the e-mail address does not contain this suffix, the field must be filled in manually. The value for Google is: "https://accounts.google.com/o/oauth2/v2/auth". |
Token URI |
The field is filled in automatically with the value intended for a Google account. The program fills it in automatically if it identifies a Google account in the E-mail address field on the General tab. The identification is based on the "*.gmail.com" suffix. If the e-mail address does not contain this suffix, the field must be filled in manually. The value for Google is: "https://oauth2.googleapis.com/token". |
Scope |
The field is filled in automatically with the value intended for a Google account. The program fills it in automatically if it identifies a Google account in the E-mail address field on the General tab. The identification is based on the "*.gmail.com" suffix. If the e-mail address does not contain this suffix, the field must be filled in manually. The value for Google is: "https://mail.google.com/". |
Update token |
The field is filled in automatically after the account is verified. For verification, press the Access token button and then use the Get/Update option. A web browser is displayed prompting you to log in to the Google account. After logging in, verification takes place and the Update token field is automatically filled in with a value. |
Expiration |
Date and time of expiry of the Update token. The token is valid for 1 hour, after which it is updated automatically. The token can also be updated manually. |
Forget/Remove token |
Removes the update token. It must then be loaded and authorized again. |
Get/Update token |
Loads the web page for authorization of the update token. |
Microsoft authorization
It is no longer possible to use so-called Basic authentication (login using a user name and password) to log in to a Microsoft account.
So if users want to use a mailbox in IS K2 for receiving and sending e-mails via protocols such as IMAP, POP3 or SMTP, they must set up so-called Modern authentification. This is authentication via the OAuth2 protocol.
Creating an application in Microsoft Azure
A prerequisite for using OAuth2 authorization is creating an application within the Microsoft Azure service. It is available at https://portal.azure.com/.
The application must then be created and set up in the Azure Active Directory section, in the App registrations part.

Picture: Creating an application within Microsoft Azure
After creating the application, you will be automatically redirected to a page with an overview of the basic data of this application. This is the Overview section.

Picture: Basic data of the application
There are two important data items here: Application (client) ID and Directory (tenant) ID. These must be entered in IS K2 in the form for setting up OAuth2 authorization.
In the menu on the left side of the page, go to the Certificates & secrets part. Here it is necessary to generate a new "secret" code. To do so, click the New client secret text.

Picture: Certificates & secrets
A page is then displayed where it is necessary to enter a Description and the Expiry of the secret.

Picture: Creating a secret
Create a new secret with the Add button.

Picture: Client secret value
After creation, we recommend copying the value of the secret ID. After the page is refreshed, this is no longer possible. This ID must also be entered in IS K2 in the form for setting up OAuth2 authorization.
In the left menu, then select the Authentication option.

Picture: Allowing public client flows
Here it is necessary to allow public client flows by clicking the Yes button. Then save the applied change with the Save button.
In the next step, select the API permissions option from the left menu.

Picture: API permissions
Here, use the Add a permission button to display a list of possible permissions that can be set. In this list, select the Microsoft Graph option.
Next, select the Delegated permissions option. A list of all available permissions is displayed. In the Mail part, select the Mail.Send option.

Picture: Setting the Mail.Send permission
In the list of permissions, in the User part, then select the User.Read option.

Picture: Setting the User.Read permission
Save the changes made with the Add permissions button. The selected permissions are saved. Use the Grant admin consent for MSFT button to grant this consent here.

Picture: Admin consent for MSFT
For further settings, display the Authentication tab in the left menu. To add a new platform, click the Add a platform button here.

Picture: Platform configuration
In the list of applications, select the Web option. Further settings for this platform are displayed.

Picture: Configuration of the Web platform
Here, in the upper part, set the Redirect URI to the value "http://localhost". In the lower part, check both flags Access tokens and ID tokens. Save the settings with the Configure button.
A comprehensive guide on how to create and set up an application in the Microsoft Azure environment is available here: https://intercom.help/security-studio/en/articles/5087114-setup-email-smtp-settings-with-office365-oauth2-authentication.
Settings in IS K2 - Microsoft
Further settings for authorization using the OAuth2 protocol must be made directly in IS K2 in the Mail / Mailbox settings module. All data for this protocol and Microsoft authorization is available via the OAuth 2. button

Picture: Button on the form for setting up the OAuth 2 protocol
Pressing the button displays a form for entering the data from the application created in the Microsoft Azure environment.

Picture: Setting up the OAuth2 protocol for Microsoft in IS K2
Description of fields:
Client ID |
Here it is necessary to enter the Application (client) ID obtained by creating the application in the Microsoft Azure environment. |
Tenant ID |
Here it is necessary to enter the Directory (tenant) ID obtained by creating the application in the Microsoft Azure environment. |
Client Secret |
Here it is necessary to enter the Client secret obtained by creating the application in the Microsoft Azure environment. |
Authorization URI |
The field is filled in automatically with the value intended for a Microsoft account. |
Token URI |
The field is filled in automatically with the value intended for a Microsoft account. |
Scope |
The field is filled in automatically with the value intended for a Microsoft account. |
Update token |
The field is filled in automatically after the account is verified. For verification, press the Access token button and then use the Get/Update option. A web browser is displayed prompting you to log in to the Microsoft account. After logging in, verification takes place and the Update token field is automatically filled in with a value. |
Expiration |
Date and time of expiry of the Update token. The token is valid for 1 hour, after which it is updated automatically. The token can also be updated manually. |
Get/Update token |
Loads the web page for authorization of the update token. |
Forget/Remove |
Removes the update token. It must then be loaded and authorized again. |
Note:
If the message "Authentication unsuccessful, SmtpClientAuthentication is disabled for the Mailbox. Visit https://aka.ms/smtp_auth_disabled for more information." appears when testing the connection, the Authenticated SMTP protocol must be enabled for the given mailbox. It can be enabled in two ways:
1. Using Exchange Online PowerShell - the command should enable Authenticated SMTP for all users.
Set-TransportConfig -SmtpClientAuthenticationDisabled $false
2. The recommended way using the admin center https://admin.microsoft.com, where the administrator enables the Authenticated SMTP protocol for the selected mailbox.






Scripts, Functions
Contact person scripts can be found in the Script catalogue.