Here you can find the source of buildEmailUri(String email, String subject, CharSequence body)
Parameter | Description |
---|---|
The email address to send the message to | |
subject | The email subject |
body | The email body |
@Nonnull public static Uri buildEmailUri(String email, String subject, CharSequence body)
//package com.java2s; /*// ww w .ja v a2 s . c o m * Copyright 2013 Luluvise Ltd * Copyright 2013 Marco Salis - fast3r(at)gmail.com * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ import javax.annotation.Nonnull; import android.net.Uri; public class Main { /** * To be used with {@link android.content.Intent.ACTION_SENDTO} to send * email, either in plain text or HTML. * * @param email * The email address to send the message to * @param subject * The email subject * @param body * The email body * @return The {@link Uri} for the intent to send the email */ @Nonnull public static Uri buildEmailUri(String email, String subject, CharSequence body) { StringBuilder builder = new StringBuilder(); builder.append("mailto:").append(email); builder.append("?subject=").append(subject); builder.append("&body=").append(body); String uriText = builder.toString().replace(" ", "%20"); return Uri.parse(uriText); } }