Created
December 1, 2019 12:11
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public synchronized void sendUserDetailWithImage(String subject, String body, | |
String sender, String recipients,String username,String email,String mobile,String dob,String age,String address,String profilePic ) throws Exception { | |
MimeMessage message = new MimeMessage(session); | |
DataHandler handler = new DataHandler(new ByteArrayDataSource(body.getBytes(), "text/plain")); | |
message.setFrom(new InternetAddress("no-reply@astromyntra.in")); | |
message.setSender(new InternetAddress(sender)); | |
message.setSubject(subject); | |
message.setDataHandler(handler); | |
BodyPart messageBodyPart = new MimeBodyPart(); | |
InputStream is = context.getAssets().open("user_profile.html"); | |
int size = is.available(); | |
byte[] buffer = new byte[size]; | |
is.read(buffer); | |
is.close(); | |
String str = new String(buffer); | |
str =str.replace("$$headermessage$$","You have got a new user."); | |
str=str.replace("$$username$$", username); | |
str=str.replace("$$email$$", email); | |
str=str.replace("$$mobile$$", mobile); | |
str=str.replace("$$dob$$",dob); | |
str=str.replace("$$age$$",age); | |
str=str.replace("$$address$$", address); | |
messageBodyPart.setContent(str,"text/html; charset=utf-8"); | |
_multipart.addBodyPart(messageBodyPart); | |
// Put parts in message | |
message.setContent(_multipart); | |
if (recipients.indexOf(',') > 0) | |
message.setRecipients(Message.RecipientType.TO, InternetAddress.parse(recipients)); | |
else | |
message.setRecipient(Message.RecipientType.TO, new InternetAddress(recipients)); | |
Transport.send(message); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment