Android sending email with css html embedded

2019-07-30 02:08发布

I am sending a mail using intent from android application but my css is not loading. can someone help me load the css please. where am i wrong. Am stuck on this silly option for hours nows.

here part of my div.

<div style="background:"+String.format(hex,colors.get(position).hex)"></div>...

1条回答
孤傲高冷的网名
2楼-- · 2019-07-30 02:48

I had the same problem, and couldnt fix it. I don't think its possible to send css with the default email clients (correct me if i'm wrong).

My work around was sending the html as a attachment.

see: Is it possible to send html with the mail intent?

Edit: here is example how i did it:

  • save the html as a file..
  • add you attachments to a list of Uri objects
  • see following code how to create a mail intent with the attachements..

    final Intent emailIntent = new Intent(android.content.Intent.ACTION_SEND_MULTIPLE);
        emailIntent.setType("text/html");
        emailIntent.putExtra(android.content.Intent.EXTRA_SUBJECT, "title");
    
        emailIntent.putExtra(Intent.EXTRA_TEXT, "email body text");
        emailIntent.putParcelableArrayListExtra(Intent.EXTRA_STREAM, uris);
        startActivity(Intent.createChooser(emailIntent, "Email:")); 
    
查看更多
登录 后发表回答