E-mail with a custom html page - android

Asked

Viewed 99 times

1

Good afternoon, Someone can help me, I am developing an app, where after receiving some user data, is performed sending an email containing this information. I’d like to use html to make the email look presentable, put some background colors in the body of the email, change the title color, that sort of thing. I have looked but not found, and what I found on the net did not work. Someone can give me a strength with this?

String[] recipients = new String[]{endEmail, "",};

StringBuilder body = new StringBuilder();
body.append("<html><body><div bgcolor='#fcaf17' style='background:#fcaf17;font-family:arial,Verdana,sans-serif'>")
                                .append("<center><table cellpadding='30' cellspacing='0' border='0' bgcolor='#fcaf17' width='100%' style='width:100%;margin:0;padding:0;font-family:arial,Verdana,sans-serif'><tbody><tr>")
                                .append(" <td> <center><br><table cellpadding='10' cellspacing='0' border='0' bgcolor='#ffffff' width='640px' style='width:640px;background:#fff;font-family:arial,Verdana,sans-serif'>")

                                .append(" <tbody><tr> <td><table cellpadding='10' cellspacing='0' border='0' bgcolor='#ffffff' width='620px' style='width:620px;text-align:left;font-family:arial,Verdana,sans-serif'>")
                                .append(" <tbody><tr> <td><img src='link imagem' alt='logo_ncgames' class='CToWUd'>")
                                .append(" </td></tr></tbody></table> <hr style='border-top:#dfdfdf!important;border-right:none;border-left:none'>")
                                .append(" <h3 style='color:#ef871e'>Contato</h3> <p>Nome : <span style='font-size:18px;font-weight:bold'>bafae596</span></p>")
                                .append(" <p>Email : <span style='font-size:18px;font-weight:bold'>bafae596</span></p><p>Telefone : <span style='font-size:18px;font-weight:bold'>bafae596</span></p>")
                                .append(" <p>Descrição : <span style='font-size:18px;font-weight:bold'>bafae596</span></p> </td></tr></tbody></table><table cellpadding='10' cellspacing='0' border='0' bgcolor='#fef3da' width='640px' style='display:block;width:640px;height:40px;font-family:arial,Verdana,sans-serif'>")
                                .append(" <tbody><tr style='color:#1d284b;text-align:center'> <td><span style='color:#ef871e;font-size:10px'>OBS:Este email é enviado pelo sistema. Por favor não responda-o. Caso tenha dúvidas entre em contato.</span>")
                                .append(" </td></tr></tbody></table><br> <br></center></td> </tr></tbody></table></center></div></body></html>");

                        String stremail =  body.toString();

                        Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND);
                        emailIntent.setType("text/html");
                        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, assunto);
                        emailIntent.putExtra(android.content.Intent.EXTRA_EMAIL, new String[]{to});
                        emailIntent.putExtra(android.content.Intent.EXTRA_TEXT, Html.fromHtml(stremail));

                        startActivity(Intent.createChooser(emailIntent, "Enviar email...."));
  • Daniel, it would be good to put the code (in your question) you have already done to carry out the sending of email. It helps to give a context of how you are doing.

  • Oh yes... I put the code...

1 answer

0

I already sent the normal html, as a String, the same way you.

Usually email clients also ignore their metatags, html, and leave only content.

You have restricted space in the email client, so set a fixed or self-adjusting width.

Desktop clients, some, do not support CSS3, so take it easy.

Try some images, from external links, might be a good choice!

Browser other questions tagged

You are not signed in. Login or sign up in order to post.