on 08-01-2013 7:23 PM
Hello IdM experts,
I'm trying to send an email notification from IdM 7.2 SP7 using JavaScript function uSendSMTPMessage. The email subject line contains German umlauts, e.g. the character 'ü' as part of the word "für". The email is sent without error messages. However, the subject line does not arrive correctly at the email recipient side. For example, character 'ü' is replaced with a pipe character '|'. As a side note: the email body also contains German umlauts; these are transferred without any problems. The issue only exists for the subject line.
I've tried working around this by using different variants of how to specify the actual umlaut in the JavaScript code:
None of these provided the correct end result after the email had been received. The receiver always gets | instead of ü.
Assuming that this problem is related to character set and codepage, I've tried using the optional parameter SubjectCodePage to the uSendSMTPMessage call, which looks exactly like what I need. According to MSDN, the codepage identifier I would need to specify for Western European encoding (i.e. ISO-8859-1) is "28591".
My problem with that approach, however, is that specifying SubjectCodePage, which is the 15th parameter to uSendSMTPMessage, would require that I specify all 14 parameters before that. That's a problem specifically for parameter number 8, Attachment, because I don't want to send any attachment. I tried supplying the parameter with
but each of these attempts failed with an exception "uSendSMTPMessage: Cannot read attached file."
Two questions here:
Best regards,
Lambert
Hello Lambert,
the charset-issue is depending on the used charset for the current installation.
Most of the Java Installations on Microsoft Windows use CP1252.
You can see this for example when you start the user-interface of the sapjco.jar/sapjco3.jar.
For sending out emails you can just change the encoding of the string itself with JAVA tools from the JVM. JAVA itself is using UTF-16 for strings internally but UTF-8 should be good for international emails including e.g. German and Chinese.
In the Javascript just do the following with your subject-string.
Import a utility-class from the JVM and use it to change the charset.
importClass(Packages.javax.mail.internet.MimeUtility);
var utfsubject = MimeUtility.encodeText(subject, "utf-8", "B");
You can specify to use UTF-8 in the body as well but this is possible with a method parameter.
You can try the following:
UserFunc.uSendSMTPMessage(sender, recipient, utfsubject, body, email_host, "text/html;charset=utf-8", email_port);
In this scenario you wouldn't need to handle the attachment.
Best Regards,
Gunnar
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
91 | |
10 | |
10 | |
9 | |
9 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.