简体   繁体   中英

Android: How to Send email using outlook with custom font using intent

I am developing android app in which i send email using intent when i send email using gmail it is working fine but when i choose outlook the body is empty.

Custom font is also not working.

Intent intent = new Intent(Intent.ACTION_SEND);
intent.putExtra(Intent.EXTRA_SUBJECT, title);

Typeface face = Typeface.createFromAsset(getAssets(), "gotham_book.otf");
SpannableStringBuilder SS = new SpannableStringBuilder(new StringBuilder()
                .append("<p>Check out this RFP I found on MWBE Connect NY:</p><br/>")
                .append("<p><b>Title: </b>"+title+"</p>")
                .append("<b><p>Agency: </b>"+agency+"<p/>")
                .append("<b><p> Description: </b>" + longdesc + "</b><p/>")
                .append("<b><p> Published: </b>" + starteddate + "</b><p/>")
                .append("<b><p> Deadline: </b>" + deadline + "</b><p/>")
                .append("<b><p> More info: </b>" + agencyurl + "</b><p/>")
                .append("<p>© 2016 Capalino+Company, New York, NY.</p>")
                .append("<p>For more information on Capalino+Company’s MWBE services, including RFP response strategy and development, please email us at mwbeconnectny@capalino.com.</p>")
                .append("<a><p>http://www.capalino.com/</p></a>")
                .toString());

SS.setSpan(face, 0, SS.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);

intent.putExtra(Intent.EXTRA_TEXT, Html.fromHtml(SS.toString()));

intent.setType("text/html");
intent.setType("message/rfc822");
startActivityForResult(Intent.createChooser(intent, "Send Email"), Constants.Content_email_Constants);

Web Fonts Do Not Work in Outlook or Gmail

Sadly for you, Gotham is not a web safe font and it's not free like a Google Font. To use it in email, you need to pay typography.com for the rights to use it and to include a link to the stylesheet they host. Unless of course the email recipient has installed the font on their own computing device.

Even in that case, it doesn't work with Outlook or Gmail. You need to choose a web safe alternative fallback like Arial or Trebuchet.

Embed a Font

You could embed a woff2 base64 encoded font, but it still doesn't work with Gmail or Outlook, it most likely would be blocked as an attachment by email clients until the recipient allowed it. In reality, it would be easier to use a link to a web font for email clients that do support web fonts.

Good luck.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM