cancel
Showing results for 
Search instead for 
Did you mean: 

How to set code page for BODY of Notification message

Former Member
0 Kudos

Hello all,

I have topic "How to set code page for Notification message", where I've got answer how to set code page for Notification.

But now I met next problem with Cyrillic symbols in body of message, not in data from IDM.

I would be happy if someone can help me to solve issue.

I set the  value "text/html; charset=windows-1251"  for parameter ContentType and now Cyrillic values from IDM store is displayed correctly.

But when I add Cyrillic symbols to template (for instance, file %$ddm.path%\Templates\ Identity Center\ Provisioning\ Notifications\RoleRevoked.tpl):

I see symbols '?????' instead of Russian text in RoleAssign.tpl:

All values from variables (for instance, <DISPLAYNAME>, marked red in image) are correct, only text from <file_name>.tpl is wrong.

Could you please help me to solve this issue?

Best regards,

Natalia.

Accepted Solutions (1)

Accepted Solutions (1)

Former Member
0 Kudos

Make sure you use an editor capable of saving the template file as UTF8 without BOM (notepad++, textpad etc. are good).

The sendmail script needs to use binary when reading the template, so: uFromFile(fullFileName ,-1,true);

(Edit: I just checked and the old provision framework notification function, sap_core_notificationByEmail, uses FALSE when reading the template files. Reading it as text could be the source of the problem)

Then the content type used in the sendSMTPmessage function should be "text/html;charset=UTF-8"

And as Steffi suggest, you could also try a simple HTML version as template:

<html>

<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">

<head>

</head>

<body>

<p>Something happened</p>

</body>

</html>

I can't see why you'd need to use windows-1251, but you can certainly try replacing UTF-8 with that as well in the HTML charset setting & content type for the sendmail function.

Br,

Chris

Former Member
0 Kudos

Dear all,

Many thanks for your advices!

It was news for me that I can use html instead of tpl .

But...

I have done the following:

1. change script "sap_core_notificationByEmail":

2.Create test job to send message:

3. Create file in NotePad++:

As result:

If I set binary for uFromFile:

I had received this letter:

And if I set binary=false for uFromFile, I had received letter in this format:

What I have done wrong? Please help me to solve problem.

Best regards,

Natalia.

Former Member
0 Kudos

Definitely don't use binary.

It looks like its lost the plot converting the cyrilic on the way through.  To test, use something common to pretty much every character set (a '.' is probably a good bet).  If that comes our right then you're looking at character set problems rather then scripting / mail problems...

Peter

Former Member
0 Kudos

Sorry, forgot to mention that once you've read the template as a binary you get a hex encoded text-blob. To decode it you use:

lTemplateText = uFromHex(mailMessage,"UTF-8");

This is the only way we found that safely keeps the original language formatting when we created the first version of the notifications for the new approvals. You'll see this is how it's used in the sap_assignmentNotification script of the template "Assignment Notification", and this we've tested with a large number of languages and charsets.

You can import this file and look at the script if you're curious:

usr\sap\IdM\Identity Center\Templates\Identity Center\Provisioning\Notifications\Assignment Notification_Task.mcc

The mc_templates table it's using is populated using the job named "Notification Templates_jobFolder.mcc" in the same folder, it reads the source templates as binaries so this is the source for the script:


If you read the template file without the binary option the original format is not kept and the template will be destroyed.

Br,

Chris

Former Member
0 Kudos

And here's how this very simplified version worked for me:


function sendMessage(Par){

  ReadString = uFromFile("C:/temp/templateRussian.txt",-1,true);

  mailText = uFromHex(ReadString ,"UTF-8");

  res = uSendSMTPMessage("per.krabsetsve@sap.com","per.krabsetsve@sap.com","Test in russian", mailText,"mail.sap.corp", "text/html;charset=UTF-8");

  uInfo(res);

}

The mail received at the top and the source as from Notepad++ below:

If I remove the binary flag it becomes garbled like your picture.

Br,

Chris

Former Member
0 Kudos

Chris,

thank you a lot for help!!! I see cyrillic symbols now in letter!

Summary:

In script sap_core_notificationByEmail:

REM string: 

//mailMessage = uFromFile(mailMessageFile, 0, false);

Add strings:

mailMessage_hex = uFromFile(mailMessageFile, 0, true);

  mailMessage = uFromHex(mailMessage_hex,"UTF-8");

Change string:

uSendSMTPMessage(mailSender, mailRecipients, mailSubject, mailMessage, mailSMTPHost, mailContentType);

to value:

uSendSMTPMessage(mailSender, mailRecipients, mailSubject, mailMessage, mailSMTPHost, "text/html; charset=utf-8");

Best regards,

Natalia.

Answers (1)

Answers (1)

Steffi_Warnecke
Active Contributor
0 Kudos

Hello Natalia,

you can create a template yourself as html-file, where you can set the code-page. You then just have to point to it in your notification task. If you look in the templates-folder, you should see other mail-templates as html-files (for the assignment-requests), so you could use those as a base for your custom templates.

You set the path to the template here in the attribute "MESSAGEFILE".

Maybe the easiest would be, to just keep the names of the files (because they are found throught the Notification Operation) and just turn them into HTML-files, so you just have to change the "tpl" here into "html".

Regards,

Steffi.