Subversion Repositories SmartDukaan

Rev

Rev 24490 | Rev 25743 | Go to most recent revision | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 24490 Rev 24593
Line 232... Line 232...
232
				helper.addAttachment(file.getName(), file);
232
				helper.addAttachment(file.getName(), file);
233
			}
233
			}
234
		}
234
		}
235
		mailSender.send(message);
235
		mailSender.send(message);
236
	}
236
	}
-
 
237
	public static class Attachment {
-
 
238
		public Attachment(String fileName, InputStreamSource inputStreamSource) {
-
 
239
			this.fileName = fileName;
-
 
240
			this.inputStreamSource = inputStreamSource;
-
 
241
		}
-
 
242
		
-
 
243
		private String fileName; 
-
 
244
		private InputStreamSource inputStreamSource;
-
 
245
		
-
 
246
		public String getFileName() {
-
 
247
			return fileName;
-
 
248
		}
-
 
249
		public void setFileName(String fileName) {
-
 
250
			this.fileName = fileName;
-
 
251
		}
-
 
252
		public InputStreamSource getInputStreamSource() {
-
 
253
			return inputStreamSource;
-
 
254
		}
-
 
255
		public void setInputStreamSource(InputStreamSource inputStreamSource) {
-
 
256
			this.inputStreamSource = inputStreamSource;
-
 
257
		}
-
 
258
		@Override
-
 
259
		public String toString() {
-
 
260
			return "Attachment [fileName=" + fileName + ", inputStreamSource=" + inputStreamSource + "]";
-
 
261
		}
-
 
262
	}
237
 
263
	
238
	public static void sendMailWithAttachment(JavaMailSender mailSender, String[] emailTo, String[] cc, String subject,
264
	public static void sendMailWithAttachment(JavaMailSender mailSender, String[] emailTo, String[] cc, String subject,
239
			String body, String fileName, InputStreamSource inputStreamSource) throws Exception {
265
			String body, String fileName, InputStreamSource inputStreamSource) throws Exception {
240
		MimeMessage message = mailSender.createMimeMessage();
266
		MimeMessage message = mailSender.createMimeMessage();
241
		MimeMessageHelper helper = new MimeMessageHelper(message, true);
267
		MimeMessageHelper helper = new MimeMessageHelper(message, true);
242
		helper.setSubject(subject);
268
		helper.setSubject(subject);
Line 248... Line 274...
248
		helper.addAttachment(fileName, inputStreamSource);
274
		helper.addAttachment(fileName, inputStreamSource);
249
		InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "SmartDukaan Care");
275
		InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "SmartDukaan Care");
250
		helper.setFrom(senderAddress);
276
		helper.setFrom(senderAddress);
251
		mailSender.send(message);
277
		mailSender.send(message);
252
	}
278
	}
-
 
279
	
-
 
280
	public static void sendMailWithAttachments(JavaMailSender mailSender, String[] emailTo, String[] cc, String subject,
-
 
281
			String body, Attachment... attachments) throws Exception {
-
 
282
		MimeMessage message = mailSender.createMimeMessage();
-
 
283
		MimeMessageHelper helper = new MimeMessageHelper(message, true);
-
 
284
		helper.setSubject(subject);
-
 
285
		helper.setText(body);
-
 
286
		if (cc != null) {
-
 
287
			helper.setCc(cc);
-
 
288
		}
-
 
289
		helper.setTo(emailTo);
-
 
290
		for(Attachment attachment: attachments ) {
-
 
291
			helper.addAttachment(attachment.getFileName(), attachment.getInputStreamSource());
-
 
292
		}
-
 
293
		InternetAddress senderAddress = new InternetAddress("noreply@smartdukaan.com", "SmartDukaan Care");
-
 
294
		helper.setFrom(senderAddress);
-
 
295
		mailSender.send(message);
-
 
296
	}
253
 
297
 
254
	public static String[] getOrderStatus(RechargeOrderStatus status) {
298
	public static String[] getOrderStatus(RechargeOrderStatus status) {
255
		if (status == null) {
299
		if (status == null) {
256
			status = RechargeOrderStatus.INIT;
300
			status = RechargeOrderStatus.INIT;
257
		}
301
		}