Skip to main content
Announcements
July 15, NEW Customer Portal: Initial launch will improve how you submit Support Cases. READ MORE

How to handle special characters in the Subject field using Qlik Application Automation Mail Connector

No ratings
cancel
Showing results for 
Search instead for 
Did you mean: 
Bjorn_Wedbratt
Former Employee
Former Employee

How to handle special characters in the Subject field using Qlik Application Automation Mail Connector

Last Update:

Nov 22, 2021 2:11:04 AM

Updated By:

Sonja_Bauernfeind

Created date:

Nov 16, 2021 1:58:46 AM

When sending emails using the Mail Connector in Qlik Application Automation, special characters in the Subject field may not be correctly formatted.

Example:

In Qlik Application Automation:

Mail subject.png

Email received:

Mail received.png

 

Solution

The Send Mail block does not have native support for special characters in the Subject input field, but only supports UTF-8 characters.  To use special characters, a Custom Code block can be used with some PHP code to format the text string to be used by the Subject input field.

Do the following:

  1. Create a Custom Code block and place it before the Send Mail block
    Automation flow.png
  2. Select the Custom Code block and make sure Language is set to PHP 7.4
  3. Change one of the default inputs to "Subject" and delete the second default input
  4. Paste the following code into the code block, replacing the example code
    $subject = $inputs['Subject'];
    $subj = addcslashes(mb_encode_mimeheader($subject, "UTF-8", "Q"), '"');
    echo $subj;
    ?>
    ​
  5. Here's the final Custom Code Block
    Custom codeblock no subject.png

  6. Edit the Send Mail block and set Subject input to use the output from the above Custom Code block
    Mail subject input codeblock.png
  7. Open the Custom Code block and enter the text to be used as a subject in the mail being sent
    Custom codeblock subject.png
  8. Run the automation to verify special characters are being correctly formatted in the email subject
    Mail subject correct.png

 

Environment

 

The information in this article is provided as-is and to be used at own discretion. Depending on tool(s) used, customization(s), and/or other factors ongoing support on the solution below may not be provided by Qlik Support.

Tags (1)
Labels (2)
Comments
jalbalat
Partner - Contributor II
Partner - Contributor II

Hi,

Although I don't have special characters and I have an error with send mail in automation: "Malformed UTF-8 characters, possibly in correctly encoded".

I have tried this solution but I have the same error.

Do you know another reason for this error?

Thanks

 

Version history
Last update:
‎2021-11-22 02:11 AM
Updated by: