	public void generateMail(List<Person> list, String lableTemplateName, String mailingTemplateName) {
		setTemplateName(mailingTemplateName);
		setLabelTemplateName(lableTemplateName);
		Person p = list.get(0);
		Site s = p.getSite();
		setSite(s);
		ArrayList<Long> ids = new ArrayList<Long>();
		for (Person person : list) {
			ids.add(person.getId());
			CommunicationHistory ch = new CommunicationHistory();
			ch.setPerson(person);
			ch.setSystemGenerated(true);
			ch.setComments("Generated mailing using template named " + getTemplateName());
			ch.setEntryType("Email");
			ch.setRecordDate(new Date());
			ch.setCustomFieldValue("template", getTemplateName());
			communicationHistoryService.maintainCommunicationHistory(ch);
		}
		Map params = getReportParameters();
		params.clear();
		params.put("Ids", ids);
		this.labelMap.clear();
		this.labelMap.put("Ids", ids);
		File tempLabelFile = runLabels();
		File tempFile = runReport();
		ResourceDescriptor labelRD = new ResourceDescriptor();
		ResourceDescriptor reportRD = new ResourceDescriptor();
		Date date = new Date();
		DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
		try {
			labelRD.setName(getLabelTemplateName() + dateFormat.format(date));
			labelRD.setLabel(labelRD.getName());
			labelRD.setDescription(labelRD.getName());
			labelRD.setParentFolder("/Reports/" + getSite().getName() + "/Content_files");
			labelRD.setUriString(labelRD.getParentFolder() + "/" + labelRD.getName());
			labelRD.setWsType(labelRD.TYPE_CONTENT_RESOURCE);
			labelRD.setResourceProperty(ResourceDescriptor.PROP_CONTENT_RESOURCE_TYPE,ResourceDescriptor.CONTENT_TYPE_PDF);
			labelRD.setIsNew(true);
			labelRD.setHasData(true);
			{
				RequestAttachment[] attachments;
				FileDataSource fileDataSource = new FileDataSource(tempLabelFile);
				RequestAttachment attachment = new RequestAttachment(fileDataSource);
				attachment.setContentID(labelRD.getName());
				attachments = new RequestAttachment[]{attachment};
			jserver.getWSClient().putResource(labelRD, attachments);
			}
			reportRD.setName(getTemplateName() + dateFormat.format(date));
			reportRD.setLabel(reportRD.getName());
			reportRD.setDescription(reportRD.getName());
			reportRD.setParentFolder("/Reports/" + getSite().getName() + "/Content_files");
			reportRD.setUriString(reportRD.getParentFolder() + "/" + reportRD.getName());
			reportRD.setWsType(reportRD.TYPE_CONTENT_RESOURCE);
			reportRD.setResourceProperty(ResourceDescriptor.PROP_CONTENT_RESOURCE_TYPE,ResourceDescriptor.CONTENT_TYPE_PDF);
			reportRD.setIsNew(true);
			reportRD.setHasData(true);
			{
				RequestAttachment[] attachments;
				FileDataSource fileDataSource = new FileDataSource(tempFile);
				RequestAttachment attachment = new RequestAttachment(fileDataSource);
				attachment.setContentID(reportRD.getName());
				attachments = new RequestAttachment[]{attachment};
				jserver.getWSClient().putResource(reportRD, attachments);
			}
			tempLabelFile.delete();
			tempFile.delete();
		} catch (Exception ex) {
			logger.error(ex.getMessage());
		}
	}

	public void generateMail(List<Person> list, String lableTemplateName, String mailingTemplateName) {
		setTemplateName(mailingTemplateName);
		setLabelTemplateName(lableTemplateName);
		Person p = list.get(0);
		Site s = p.getSite();
		setSite(s);
		ArrayList<Long> ids = new ArrayList<Long>();
		for (Person person : list) {
			ids.add(person.getId());
			CommunicationHistory ch = new CommunicationHistory();
			ch.setPerson(person);
			ch.setSystemGenerated(true);
			ch.setComments("Generated mailing using template named " + getTemplateName());
			ch.setEntryType("Mail");
			ch.setRecordDate(new Date());
			ch.setCustomFieldValue("template", getTemplateName());
			communicationHistoryService.maintainCommunicationHistory(ch);
		}
		Map params = getReportParameters();
		params.clear();
		params.put("Ids", ids);
		this.labelMap.clear();
		this.labelMap.put("Ids", ids);
		File tempLabelFile = runLabels();
		File tempFile = runReport();
		ResourceDescriptor labelRD = new ResourceDescriptor();
		ResourceDescriptor reportRD = new ResourceDescriptor();
		Date date = new Date();
		DateFormat dateFormat = new SimpleDateFormat("yyyyMMddHHmmss");
		try {
			labelRD.setName(getLabelTemplateName() + dateFormat.format(date));
			labelRD.setLabel(labelRD.getName());
			labelRD.setDescription(labelRD.getName());
			labelRD.setParentFolder("/Reports/" + getSite().getName() + "/Content_files");
			labelRD.setUriString(labelRD.getParentFolder() + "/" + labelRD.getName());
			labelRD.setWsType(labelRD.TYPE_CONTENT_RESOURCE);
			labelRD.setResourceProperty(ResourceDescriptor.PROP_CONTENT_RESOURCE_TYPE,ResourceDescriptor.CONTENT_TYPE_PDF);
			labelRD.setIsNew(true);
			labelRD.setHasData(true);
			{
				RequestAttachment[] attachments;
				FileDataSource fileDataSource = new FileDataSource(tempLabelFile);
				RequestAttachment attachment = new RequestAttachment(fileDataSource);
				attachment.setContentID(labelRD.getName());
				attachments = new RequestAttachment[]{attachment};
			jserver.getWSClient().putResource(labelRD, attachments);
			}
			reportRD.setName(getTemplateName() + dateFormat.format(date));
			reportRD.setLabel(reportRD.getName());
			reportRD.setDescription(reportRD.getName());
			reportRD.setParentFolder("/Reports/" + getSite().getName() + "/Content_files");
			reportRD.setUriString(reportRD.getParentFolder() + "/" + reportRD.getName());
			reportRD.setWsType(reportRD.TYPE_CONTENT_RESOURCE);
			reportRD.setResourceProperty(ResourceDescriptor.PROP_CONTENT_RESOURCE_TYPE,ResourceDescriptor.CONTENT_TYPE_PDF);
			reportRD.setIsNew(true);
			reportRD.setHasData(true);
			{
				RequestAttachment[] attachments;
				FileDataSource fileDataSource = new FileDataSource(tempFile);
				RequestAttachment attachment = new RequestAttachment(fileDataSource);
				attachment.setContentID(reportRD.getName());
				attachments = new RequestAttachment[]{attachment};
				jserver.getWSClient().putResource(reportRD, attachments);
			}
			tempLabelFile.delete();
			tempFile.delete();
		} catch (Exception ex) {
			logger.error(ex.getMessage());
		}
	}
