Email Plugin Configuration

Using Linx, you are able to integrate with Email applications in order to read and send emails.

The Linx Email plugin contains two functions which are ReadEmail and SendEmail respectively.

This post will detail how to setup both of these functions to integrate with your mailbox.

The explanations and sample are mostly for Linx5 users. We`ve included a sample for Linx 6 users.

Feel free to contact support@linx.software and we’ll assist.

:floppy_disk: Sample Solutions

Linx 5.22.0 LinxEmailSolution.lsoz (10.1 KB)

Linx 6.0.5 Linx6.zip (12.0 KB)

Before you begin, you must have the Email Plugin installed for your solution.


Please note the terms ‘Process’ and ‘Custom Type’ have been depreciated and have been replaced with ‘Function’ and ‘Type’ respectively. More details here.


SendEmail

The SendEmail function is used to send emails to an SMTP server for distribution to recipient.

If you do not have a dedicated SMTP server, you can make use of Gmail’s one provided for you if you have an account.

To begin, we are just going to add a SendMail function by dragging it from the Plugins panel onto the Function(Linx 5.20.2.0) panel.

image

There are a number of properties that need to be configured before we can connect to the email client:

First, we need to link it to a SMTP server, simply reference the server name, in this example I am using Gmails built in SMTP server:

Server

Smtp server: smtp.gmail.com

Credentials

Username: your mail account user name

Password: your mail account password

Note: In some cases like gmail, you will need to configure an App specific password for Linx to connect, further instructions can be found here.

Options

Enable SSL: True

Port: 25

Now that we have setup the configuration, we can send a test email.

To send a mail, at a minimum the following need to be completed:

Receivers:

To: email address that you want to send to

Senders:

From: email address you want to send as

Note: if your SMTP server is setup to be able to send as whatever you like then you can fill this in. By default, it will send with the smtp servers default settings. In the case of using a personal gmail account it will send as the accounts owner.

If you debug/run the Function(Linx 5.20.2.0) you should see the Function(Linx 5.20.2.0) successfully complete and a mail arrive in the target mailbox.

Additional Options

There are a number of other properties that you can configure in terms of the SendEmail.

Content:

Subject: the subject line that you want to appear on the mail.

Text body: the body of the email, if using this property, the mail will be sent as plain text.

Html body: the body of the email, if using this property, the mail will be sent as HTML. Note: If both the Text and HTML fields are used, the HTML body will override whatever is in the ‘Text body’ field.

Attachments:

Add an attachment, or multiple attachments by referencing the file paths of the attachments. For multiple attachments, you will need to build up a list and then add it to this property (this is demonstrated in the demo solution).

Note: The above fields can also be references to outputs, settings and local types in the usual Linx manner, the demo example demonstrates these.

Example:

An example of the above configuration is found in the Demo solution: ‘LinxEmailSolution’, in the Function(Linx 5.20.2.0) ‘SendEmailDemo’. This Function(Linx 5.20.2.0) retrieves names, email addresses and attachments from a database and these uses these values for sending the email.

image

image

ReadEmail

The ReadEmail function will connect to a mail server using either IMAP or POP3.

Reading Emails via Pop3

POP (Post Office Protocol) implements the offline mail access model, where mail is retrieved and then deleted from the server where the mailbox resides so it can be used on a local machine. Emails are hence transferred permanently from a central server to one client machine.

image

ReadMail Properties:

Similar to the above SendMail section, you need to configure your function to connect to your mail box. Using the same account as the example above:

Mail server settings

Server name: pop.gmail.com

User name: Username of your account

Password: Password of your account

Port: 995

Use SSL: True

Options

Delete after read: tick this if you want the email removed from your mailbox

Body as HTML: tick this if you want the email body returned as formatted HTML

Attachment Options:

  • None: will ignore attachments.

  • SaveToFile: will save the attachments as files to the specified directory. The filepath is an automatic output of this function and can be used to use an attachment later in the Function.

  • ReturnData: will convert the attachment contents to a string and allow you to use that string further down in your Function. This option will only work for text-based attachments, not binary ones.

Note: Both SaveToFile and ReturnData can both be selected.

Save email: set to true to save the whole email to disk

File directory: Directory where email and/or attachments will be saved to.

Email file type:

  • Eml

  • tnef

You can test this by running Function (Linx 5.22.0.0) and the ReadEmail function will start to return email objects.

To enhance this Function(Linx 5.22.0.0) by making use of filtering please this post.

Reading Emails via IMAP

IMAP (Internet Message Access Protocol) provides access and retrieve mail functions for a remote mail server so the mails can be used locally while retaining them also on the server. IMAP sets message flags so that the user can keep track of which messages he or she has already seen, already answered, and so on.

image

ReadMail Properties:

Similar to the above SendMail section, you need to configure your function to connect to your mail box. Using the same account as the example above:

Mail server settings

Server name: imap.gmail.com

User name: Username of your account

Password: Password of your account

Port: 993

Use SSL: True

Options

Folder: This is the folder in you actual mailbox that you want to search through i.e Inbox

Only unread items: Tick this if you want to scan unopened emails

Mark as read: Tick this if you want the mails that Linx retrieves to be marked as ‘read’.

Move to folder: This is a folder in your actual mailbox that you want the retrieved email to be moved to.

Delete after read: Tick this if you want the emails retrieved by Linx to be deleted from your mail box.

Body as HTML: Set to true to retrieve the email’s body formatted as HTML.

Attachment Options:

  • None: will ignore attachments.

  • SaveToFile: will save the attachments as files to the specified directory. The filepath is an automatic output of this function and can be used to use an attachment later in the Function.

  • ReturnData: will convert the attachment contents to a string and allow you to use that string further down in your Function. This option will only work for text-based attachments, not binary ones.

Save email: set to true to save the whole email to disk

File directory: Directory where email and/or attachments will be saved to.

Email file type:

  • Eml

  • tnef

You can test this by running your Function(Linx 5.22.0.0) and the ReadEmail function will start to return email objects.

To enhance this Function(Linx 5.22.0.0) by making use of filtering please this post.