如何通过速度模板发送阿拉伯语的电子邮件

发布于 2025-02-05 21:05:03 字数 373 浏览 3 评论 0原文

我将UTF-8用作字符编码。但仍然确实获得了适当的输出。

message.setSubject(emailSubject,"UTF-16");

message.setSubject(emailSubject,"UTF-8");
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent(emailBody, "text/html; charset=UTF-8");

电子邮件内容看起来像这样

I used UTF-8 as character encoding. but still did get the proper output.

message.setSubject(emailSubject,"UTF-16");

message.setSubject(emailSubject,"UTF-8");
BodyPart messageBodyPart = new MimeBodyPart();
messageBodyPart.setContent(emailBody, "text/html; charset=UTF-8");

EMail content is looks like this

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

风和你 2025-02-12 21:05:03

什么时候”?有2个选项。

  1. 信息完好无损,但是显示信息的客户端并不知道如何正确显示信息。
  2. 该信息实际上被损坏/丢失。

当我诊断出此类问题时,对我有很大帮助的是将信息转换为Unicode序列,而您可以清楚地看到您的信息是否有效或损坏
我有一个由我编写和维护的开源java库mgntutils,它具有将字符串转换为Unicode序列的实用程序,反之亦然:

result = "Hello World";
result = StringUnicodeEncoderDecoder.encodeStringToUnicodeSequence(result);
System.out.println(result);
result = StringUnicodeEncoderDecoder.decodeUnicodeSequenceToString(result);
System.out.println(result);

该代码的输出是:

\u0048\u0065\u006c\u006c\u006f\u0020\u0057\u006f\u0072\u006c\u0064
Hello World

可以在 github 它以maven fors and succes and succes和javadoc的形式出现

,是班级的javadoc stringunicodeencodencoderdecoder

除非使用它来诊断问题,否则您可以将文本进行诊断,然后将其转换为Unicode序列,然后将其转换为Unicode序列并发送该文本而不是文本。在这种情况下,您没有任何转换,任何系统都应正确显示符号。缺点是信息大小大于原始文本

When you get "?" there are 2 options.

  1. Information is intact but the client that displays the info doesn't know how to properly display the info.
  2. The information actually got corrupted/lost.

What helped me a lot when I diagnosed such issues was to convert the information into unicode sequences and than you can clearly see if your info is valid or corrupted
There is an Open Source java library MgntUtils written and maintained by me that has a Utility that converts Strings to unicode sequence and vise versa:

result = "Hello World";
result = StringUnicodeEncoderDecoder.encodeStringToUnicodeSequence(result);
System.out.println(result);
result = StringUnicodeEncoderDecoder.decodeUnicodeSequenceToString(result);
System.out.println(result);

The output of this code is:

\u0048\u0065\u006c\u006c\u006f\u0020\u0057\u006f\u0072\u006c\u0064
Hello World

The library can be found at Maven Central or at Github It comes as maven artifact and with sources and javadoc

Here is javadoc for the class StringUnicodeEncoderDecoder

Except using it to diagnose the issue you can just take your text and convert it to unicode sequences and send that instead of text. in this case you don't have any conversions and the symbols should be displayed correctly by any system. The drawback is that the information size is larger then original text

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文