Commit 47f8b553 authored by Prayas Jain's avatar Prayas Jain

Corrected Filename for the sent file in email

parent 154e0509
...@@ -15,7 +15,6 @@ import org.springframework.mail.javamail.JavaMailSender; ...@@ -15,7 +15,6 @@ import org.springframework.mail.javamail.JavaMailSender;
import org.springframework.mail.javamail.MimeMessageHelper; import org.springframework.mail.javamail.MimeMessageHelper;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.ResourceUtils; import org.springframework.util.ResourceUtils;
import org.thymeleaf.spring4.SpringTemplateEngine;
import javax.activation.DataHandler; import javax.activation.DataHandler;
import javax.mail.MessagingException; import javax.mail.MessagingException;
...@@ -153,17 +152,17 @@ public class MailService implements IMailService { ...@@ -153,17 +152,17 @@ public class MailService implements IMailService {
MimeMessageHelper helper = new MimeMessageHelper(message,true); MimeMessageHelper helper = new MimeMessageHelper(message,true);
MimeMultipart multipart = new MimeMultipart("related"); MimeMultipart multipart = new MimeMultipart("related");
MimeBodyPart messageBodyPart = new MimeBodyPart(); MimeBodyPart messageBodyPart = new MimeBodyPart();
String htmlText = "<img src=\"cid:HappyAnniversary.png\">"; String htmlText = "<img src=\"cid:HappyWorkAnniversary.png\">";
messageBodyPart.setContent(htmlText, "text/html"); messageBodyPart.setContent(htmlText, "text/html");
multipart.addBodyPart(messageBodyPart); multipart.addBodyPart(messageBodyPart);
messageBodyPart = new MimeBodyPart(); messageBodyPart = new MimeBodyPart();
InputStream targetStream = servletContext.getResourceAsStream("/WEB-INF/images/HappyAnniversary.png"); InputStream targetStream = servletContext.getResourceAsStream("/WEB-INF/images/HappyWorkAnniversary.png");
ByteArrayDataSource ds = new ByteArrayDataSource(targetStream, "image/png"); ByteArrayDataSource ds = new ByteArrayDataSource(targetStream, "image/png");
messageBodyPart.setDataHandler(new DataHandler(ds)); messageBodyPart.setDataHandler(new DataHandler(ds));
messageBodyPart.setHeader("Content-ID", "<HappyAnniversary.png>"); messageBodyPart.setHeader("Content-ID", "<HappyWorkAnniversary.png>");
messageBodyPart.setDisposition(MimeBodyPart.INLINE); messageBodyPart.setDisposition(MimeBodyPart.INLINE);
messageBodyPart.setFileName("HappyAnniversary.png"); messageBodyPart.setFileName("HappyWorkAnniversary.png");
multipart.addBodyPart(messageBodyPart); multipart.addBodyPart(messageBodyPart);
message.setContent(multipart); message.setContent(multipart);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment