SoFunction
Updated on 2025-03-11

Small examples of the email sending function of Android calling system


package ;

import ;
import ;

import ;
import ;
import ;

public class SendEmailUtils {
    private SendEmailUtils(){}
    private static SendEmailUtils instance;
    public static SendEmailUtils getInstance(){
        synchronized () {
            if(instance == null){
                instance = new SendEmailUtils();
            }
        }
        return instance;
    }
    /**
* This is a simple test, does not support with attachments, multiple people, cc sending, etc.
     * @param context
     */
    public void sendEmail(Context context){
        Intent intent = new Intent();
        (("mailto:"));
/*Set the title of the email*/
(Intent.EXTRA_SUBJECT, "Don't be nervous, this is just a test!");
/*Set the content of the email*/
(Intent.EXTRA_TEXT, "Test opens the system mailbox and automatically fills the sent title and content to the mailbox, and sends the email,");
//Start the call
        (intent);
    }
    /**
* Send an email, cc, and send a secret, and bring an attachment
     * @param context
     */
    public void sendEmailDuo(Context context){
        Intent intent = new Intent(Intent.ACTION_SEND);
//        (("mailto:"));
        String[] tos = { "yw.1@" };
        String[] ccs = { "yw.2@" };
        String[] bccs = {"yw.3@"};
(Intent.EXTRA_EMAIL, tos); //Recipient
(Intent.EXTRA_CC, ccs); //Cc this
(Intent.EXTRA_BCC, bccs); //Send this secretly
(Intent.EXTRA_TEXT, "Email Content");
(Intent.EXTRA_SUBJECT, "Mail Title");

        (Intent.EXTRA_STREAM, ("file:///mnt/sdcard/"));
        ("image/*");
        ("message/rfc882");
        (intent, "Choose Email Client");
        (intent);

    }
    /**
* Multiple attachments sent
     * @param conext
     */
    public void sendFujian(Context conext){
        Intent intent = new Intent(Intent.ACTION_SEND_MULTIPLE);
        String[] tos = { "@" };
        String[] ccs = { "@" };
        (Intent.EXTRA_EMAIL, tos);
        (Intent.EXTRA_CC, ccs);
        (Intent.EXTRA_TEXT, "body");
        (Intent.EXTRA_SUBJECT, "subject");

        List<Uri> imageUris = new ArrayList<Uri>();
        (("file:///mnt/sdcard/"));
        (("file:///mnt/sdcard/"));
        (Intent.EXTRA_STREAM, imageUris);
        ("image/*");
        ("message/rfc882");
        (intent, "Choose Email Client");
        (intent);
    }

}