Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

In Mail question mark is coming in place of special characters

Avatar

Avatar
Validate 10
Level 3
sunitac2231600
Level 3

Likes

4 likes

Total Posts

90 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 10
View profile

Avatar
Validate 10
Level 3
sunitac2231600
Level 3

Likes

4 likes

Total Posts

90 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 10
View profile
sunitac2231600
Level 3

01-11-2016

Hi All,

I have a simple abc.txt email template under /etc/notification/email .

**************************abc.txt****************************

<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<pre style="white-space:normal;">
    <table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
         <br/><br/>
          ${pages} 
    </table>
</pre>
</body>
</html>

Whenever off time property will be changed the mail will be triggered. For this code is written as below.

In onevent we are calling below

emailService.sendEmail(EMAIL_TEMPLATE_PATH,emailParamsThirty,groupEmail);

******************************EMAIL CODE*********************************

private Map<String, String> prepareEmailParams(ResourceResolver resourceResolver, String pagePath)  {                
                final Map<String, String> emailParams = new HashMap<String,String>();        
                String pagePath = resourceResolver.map(page.getPath()); 
                strBufferPages.append("<li><a href='").append(pagePath).append(".html").append("'>");
                strBufferPages.append("第65回日");  --------THIS ONE WHEN WE WILL GET IN MAIL IT IS COMING LIKE ?65??

                strBufferPages.append("</a></li>");
                strBufferPages.append("</ul> </td></tr>");                
                //LOGGER.info("pagesExists ========== +++++++++++++ ==== " + strBufferPages.toString());
                emailParams.put("pages", strBufferPages.toString());                
    }

But When I am getting mail , the UTF-8 is removed and it is coming like ?65??

Can anybody please help me on this.

Thanks in advance.

Replies

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

01-11-2016

Looks like an encoding issue. Set the encoding in the message content header - for example:

msg.setContent(message, "text/plain; charset=UTF-8");

Avatar

Avatar
Validate 1
Level 1
kolpur
Level 1

Like

1 like

Total Posts

9 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back
Boost 1
View profile

Avatar
Validate 1
Level 1
kolpur
Level 1

Like

1 like

Total Posts

9 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back
Boost 1
View profile
kolpur
Level 1

01-11-2016

You might need to use the following:

sb.append(new String(bytes, charset));

Avatar

Avatar
Validate 10
Level 3
sunitac2231600
Level 3

Likes

4 likes

Total Posts

90 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 10
View profile

Avatar
Validate 10
Level 3
sunitac2231600
Level 3

Likes

4 likes

Total Posts

90 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 10
View profile
sunitac2231600
Level 3

01-11-2016

Hi Scott,

Yes it is an encoding issue. I am using AEM 6.0 SP1. Also I have set the default parameter encoding as UTF-8 , as shown in below screenshot.

I am new to AEM. So can you please tell me where can I Set the below encoding in the message content header?

Avatar

Avatar
Validate 10
Level 3
sunitac2231600
Level 3

Likes

4 likes

Total Posts

90 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 10
View profile

Avatar
Validate 10
Level 3
sunitac2231600
Level 3

Likes

4 likes

Total Posts

90 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 10
View profile
sunitac2231600
Level 3

01-11-2016

Hi Srini,

I tried the code suggested by you in my java code. But still I am getting Question marks (?65??).

******************CHANGED CODE*******************

                String pageTitle1 = "第65回日";
                pageTitle1  = new String(pageTitle1.getBytes("UTF-8"));

                strBufferPages.append("<li><a href='").append(externLink).append(".html").append("'>");
                strBufferPages.append(pageTitle1);
                strBufferPages.append("</a></li>");
                strBufferPages.append("</ul> </td></tr>");

Avatar

Avatar
Validate 1
Level 1
kolpur
Level 1

Like

1 like

Total Posts

9 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back
Boost 1
View profile

Avatar
Validate 1
Level 1
kolpur
Level 1

Like

1 like

Total Posts

9 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back
Boost 1
View profile
kolpur
Level 1

02-11-2016

Hi Sunita,

1. Try to put the hard-coded Japanese string in the mail (abc.txt) directly and check if you are getting it right - if this is working, then it means you are not encoding it properly while setting the params

2. If above works, try setting the Japanese string only (new String(pageTitle.getBytes("UTF-8"))), then use the StringBuilder to append the full html.

Avatar

Avatar
Validate 10
Level 3
sunitac2231600
Level 3

Likes

4 likes

Total Posts

90 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 10
View profile

Avatar
Validate 10
Level 3
sunitac2231600
Level 3

Likes

4 likes

Total Posts

90 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 10
View profile
sunitac2231600
Level 3

02-11-2016

Hi Srini,

Thanks a lot for your help. Yes I put directly in abc.txt as shown below. AND IT IS NOT COMING FINE. It is coming as  ?65??

**************************abc.txt****************************

<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<pre style="white-space:normal;">
    <table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
         <br/><br/>
       
第65回日
    </table>
</pre>
</body>
</html>

What to do next step ?

Avatar

Avatar
Validate 1
Level 1
kolpur
Level 1

Like

1 like

Total Posts

9 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back
Boost 1
View profile

Avatar
Validate 1
Level 1
kolpur
Level 1

Like

1 like

Total Posts

9 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Give Back 5
Give Back 3
Give Back
Boost 1
View profile
kolpur
Level 1

02-11-2016

Hi Sunita,

Check the email headers you received if its encoded in UTF-8 (i think it wouldn't be). What is the emailService class you are using to send email?OOB or custom?If custom, ensure you are setting the encoding to the email.

Avatar

Avatar
Validate 10
Level 3
sunitac2231600
Level 3

Likes

4 likes

Total Posts

90 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 10
View profile

Avatar
Validate 10
Level 3
sunitac2231600
Level 3

Likes

4 likes

Total Posts

90 posts

Correct Reply

0 solutions
Top badges earned
Validate 10
Validate 1
Ignite 5
Ignite 3
Ignite 10
View profile
sunitac2231600
Level 3

02-11-2016

Hi Srini,

I check the email headers and UTF-8 is there , as shown below.

**************EMAIL HEADER *********************

<html>
<head>
<meta charset="utf-8">
<title>Untitled Document</title>
</head>

<body>
<pre style="white-space:normal;">
    <table width="100%" border="0" cellpadding="0" cellspacing="0" align="center">
         <br/><br/>
        ?65??
    </table>
</pre>
</body>
</html>

I am using OOB for email , as shown below.

****************************EmailService Class******************

import com.adobe.acs.commons.email.EmailService;

@Reference
EmailService emailService; 
Map<String, String> emailParams = prepareEmailParams(resourceResolver,path);
emailService.sendEmail(EMAIL_TEMPLATE_PATH,emailParams, groupEmail);

Please let me know what to do next step ....

Avatar

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile

Avatar
Validate 25
Level 10
smacdonald2008
Level 10

Likes

1,408 likes

Total Posts

12,671 posts

Correct Reply

2,278 solutions
Top badges earned
Validate 25
Validate 10
Validate 1
Give back 900
Give back 600
View profile
smacdonald2008
Level 10

02-11-2016

In your Java code - have you set proper encoding as well?