Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 19 additions & 20 deletions gxmail/src/main/java/com/genexus/internet/SMTPSession.java
Original file line number Diff line number Diff line change
Expand Up @@ -623,8 +623,25 @@ private void sendAttachment(String sTime, String fileNamePath, String attachment
try {
fis = new FileInputStream(attachmentPath + fileNamePath);
is = fis;
}
catch (FileNotFoundException e) {

println(getNextMessageIdMixed(sTime, false));
println("Content-Type: " + "application/octet-stream");
println("Content-Transfer-Encoding: " + "base64");
println("Content-Disposition: " + "attachment; filename=\"" + GXMailer.getEncodedString(fileName) + "\"");
println("");

int BUFFER_SIZE = 4096;
byte[] buffer = new byte[BUFFER_SIZE];
OutputStream base64Output = new Base64OutputStream(outStream);
int n = is.read(buffer, 0, BUFFER_SIZE);
while (n >= 0) {
base64Output.write(buffer, 0, n);
n = is.read(buffer, 0, BUFFER_SIZE);
}
base64Output.flush();
outStream.writeBytes(CRLF);
outStream.flush();
} catch (FileNotFoundException e) {
log ("11 - FileNotFound " + e.getMessage());
throw new GXMailException("Can't find " + attachmentPath + fileNamePath, MAIL_InvalidAttachment);
} finally {
Expand All @@ -633,24 +650,6 @@ private void sendAttachment(String sTime, String fileNamePath, String attachment
if (fis != null)
fis.close();
}

println(getNextMessageIdMixed(sTime, false));
println("Content-Type: " + "application/octet-stream");
println("Content-Transfer-Encoding: " + "base64");
println("Content-Disposition: " + "attachment; filename=\"" + GXMailer.getEncodedString(fileName) + "\"");
println("");

int BUFFER_SIZE = 4096;
byte[] buffer = new byte[BUFFER_SIZE];
OutputStream base64Output = new Base64OutputStream(outStream);
int n = is.read(buffer, 0, BUFFER_SIZE);
while (n >= 0) {
base64Output.write(buffer, 0, n);
n = is.read(buffer, 0, BUFFER_SIZE);
}
base64Output.flush();
outStream.writeBytes(CRLF);
outStream.flush();
}

private void println(String s) throws IOException
Expand Down