HTML formatted text in an email in Java

前端 未结 4 474
花落未央
花落未央 2021-01-15 22:12
     try{
        String msg=\"Happy BirthDay Dear, \"+name.toUpperCase()+\"  !!! Have a Great Day. \\n \\n Thank You \\n Seva Development \";
            


        
4条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-15 22:45

    This worked for me, I have changed two line code, Thank you all for your contribution

    private void sendEmail(String email,String name) throws Exception{
        Thread thread=new Thread(){
            @Override
            public void run() {
    
                try{
                    String msg="Dear "+name.toUpperCase()+" ,

    On Behalf of someone we would like to wish you a Many many Happy returns of the day

    Happy Birthday and Have a Great Day.

    \n \n Thank You!"; MimeMessage message = mailSender.createMimeMessage(); MimeMessageHelper helper = new MimeMessageHelper(message,true); helper.setTo(email); helper.setText(msg); message.setContent(msg, "text/html"); helper.setSubject("BirthDay"); mailSender.send(message); }catch (Exception e){} } }; thread.start(); }

提交回复
热议问题