[英]How to work library gmailbackground withAttachments
I want to email all the jpg format photos in a folder我想通过电子邮件发送文件夹中的所有 jpg 格式照片
BackgroundMail.newBuilder(this)
.withUsername("mail")
.withPassword("password")
.withSenderName("backup")
.withMailTo("")
.withMailCc("")
.withMailBcc("")
.withType(BackgroundMail.TYPE_PLAIN)
.withSubject("backup")
.withBody(ll)
.withAttachments()
How to use .withAttachments()
method?如何使用
.withAttachments()
方法?
Lib implemention 'com.github.luongvo:GmailBackground:2.1.1'
Lib
implemention 'com.github.luongvo:GmailBackground:2.1.1'
Please help me send all image.jpg folder /storage/sdcard0/backup请帮我发送所有image.jpg文件夹/storage/sdcard0/backup
first of all get all your jpg files into an ArrayList
called images
, I suggest to use Environment.getExternalStorageDirectory()
to get to the SD Card首先将所有 jpg 文件放入名为
images
的ArrayList
,我建议使用Environment.getExternalStorageDirectory()
获取 SD 卡
File folder = new File(Environment.getExternalStorageDirectory().getPath()+"/backup");
File[] listOfFiles = folder.listFiles();
ArrayList<String> images = new ArrayList<String>();
for (int i = 0; i < listOfFiles.length; i++) {
if (listOfFiles[i].getName().endsWith(".jpg")) {
images.add(listOfFiles[i].getPath());
}
}
put this ArrayList
as parameter in your method .withAttachments(images)
将此
ArrayList
作为参数放入您的方法.withAttachments(images)
and don't forget to set READ_EXTERNAL_STORAGE permission in your manifiest并且不要忘记在您的清单中设置 READ_EXTERNAL_STORAGE 权限
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.