while sending the email with the attachment, i am getting the subjected error. it is working fine with local system file location(eg. C://PrepaidEMFiles//invoice123.pdf) but when i am using (http://182.18.177.27:78/PrepaidEMFiles/invoice1547033786877.pdf) location i am getting the error.below is my code.
try{
`enter code here`....
String samplePdf =
"http://182.18.177.27:78/PrepaidEMFiles/invoice1547033786877.pdf";
FileSystemResource file = new FileSystemResource(samplePdf);
helper.addAttachment(file.getFilename(), file);
} catch (MessagingException e) {
LOGGER.error("Exception in sending mail", e);
exceptionHandlerDao.exceptionHandlineCode(e, "SENDING EMAIL FOR " +
inventoryName + " FOR RECHARGE A DEVICE", "");
}
sender.send(message);
}
I have tried with varies way to ignore "\" like(
eg.http:\\\\182.18.177.27:78\\PrepaidEMFiles\\invoice1547033786877.pdf) but still getting the same error.Could someone please help me with that error.
thanks in advance!!
i have tried various ways to get the file with URL url = inputstream example. but i am getting the binary file as a attachment.Still no use.
Complete error: java.nio.file.InvalidPathException: Illegal char <:> at index 4:
http:\182.18.177.27:78\PrepaidEMFiles\invoice1547033786877.pdf
at
sun.nio.fs.WindowsPathParser.normalize(WindowsPathParser.java:182)
at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:153)
at sun.nio.fs.WindowsPathParser.parse(WindowsPathParser.java:77)
at sun.nio.fs.WindowsPath.parse(WindowsPath.java:94)
at sun.nio.fs.WindowsFileSystem.getPath(WindowsFileSystem.java:255)
at java.io.File.toPath(File.java:2234)
at org.springframework.core.io.FileSystemResource.<init>
(FileSystemResource.java:82)
at
I need that remotely located pdf file to send it to email attachment.