mirror of
https://github.com/M66B/FairEmail.git
synced 2024-12-26 17:57:16 +00:00
Fixed sending with attachments
This commit is contained in:
parent
190daefe0e
commit
83cfee5711
2 changed files with 25 additions and 1 deletions
|
@ -965,9 +965,11 @@ public class FragmentCompose extends FragmentEx {
|
|||
|
||||
// Restore attachments
|
||||
for (EntityAttachment attachment : attachments) {
|
||||
File file = EntityAttachment.getFile(context, attachment.id);
|
||||
attachment.id = null;
|
||||
attachment.message = draft.id;
|
||||
db.attachment().insertAttachment(attachment);
|
||||
attachment.id = db.attachment().insertAttachment(attachment);
|
||||
Helper.copy(file, EntityAttachment.getFile(context, attachment.id));
|
||||
}
|
||||
|
||||
EntityOperation.queue(db, draft, EntityOperation.SEND);
|
||||
|
|
|
@ -34,8 +34,13 @@ import android.widget.Spinner;
|
|||
import com.google.android.material.bottomnavigation.BottomNavigationView;
|
||||
|
||||
import java.io.BufferedReader;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.io.FileOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.io.InputStreamReader;
|
||||
import java.io.OutputStream;
|
||||
import java.io.UnsupportedEncodingException;
|
||||
|
||||
import javax.mail.Address;
|
||||
|
@ -137,4 +142,21 @@ public class Helper {
|
|||
a[0] = a[0].split("\\+")[0];
|
||||
return TextUtils.join("@", a);
|
||||
}
|
||||
|
||||
static void copy(File src, File dst) throws IOException {
|
||||
InputStream in = new FileInputStream(src);
|
||||
try {
|
||||
OutputStream out = new FileOutputStream(dst);
|
||||
try {
|
||||
byte[] buf = new byte[4096];
|
||||
int len;
|
||||
while ((len = in.read(buf)) > 0)
|
||||
out.write(buf, 0, len);
|
||||
} finally {
|
||||
out.close();
|
||||
}
|
||||
} finally {
|
||||
in.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue