2013-01-31 178 views
2

我需要每天發送一封電子郵件(以HTML格式)與我的網頁中註冊的人員。我使用Grails插件「郵件」發送電子郵件。它發送沒有問題。但是,郵件發送時沒有回車,顯然這會導致郵件幾乎不可讀。這是代碼:在HTML中添加回車

ArrayList users=User.findAllByRegistradaBetween(date-1,date) 
String results="\r\n" 
for (int i=0;i<users.size();i++){ 
results = results+users[i].mail+"\r\n" 
mailService.sendMail { 

    to '[email protected]' 
    from "[email protected]" 
    subject "A subject" 
    html '<label>Users registered today: '+results+'</label></br>' 
    } 

我試過用\ r \ n,但沒有用,正如我懷疑的那樣,用HTML編寫。我怎樣才能得到類似的東西?:

[email protected]

[email protected]

[email protected]

謝謝!

+2


試過嗎? – Serhiy

回答

2

你應該嘗試使用HTML換行符而不是<br />,電子郵件是HTML,所以這應該工作得很好。

results = results+users[i].mail+"<br />"

+1

是的,它的工作,當然。多麼愚蠢的問題!謝謝你們...... – Fustigador

+0

沒問題,把這個標記爲答案,如果你喜歡^ _^ – Seer

+0

是的,當然,我曾試過,但說過我必須等4分鐘。有你的投票:) – Fustigador

-1

你可以嘗試獨立於操作系統的新行:

System.getProperty("line.separator");