
package sgc.portal.com.sym.mail.service;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import lombok.extern.slf4j.Slf4j;
import sgc.portal.base.Profiles;
import sgc.portal.base.util.EasyHashMap;
import sgc.portal.com.sym.mail.model.Mail;
import sgc.portal.com.sym.mail.model.SmtpAuth;
import sgc.portal.com.sym.mail.persistence.MailMapper;
import sgc.portal.security.model.Authority;
import org.springframework.core.env.Environment;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import sgc.portal.com.sym.batch.model.Batch;
import sgc.portal.com.sym.batch.model.FamilyEventBatch;
import sgc.portal.com.sym.batch.persistence.FamilyEventBatchMapper;

@Slf4j
@Service
@Transactional
public class MailService {
	
    @Autowired
    private MailMapper mailMapper;
    
    @Autowired
    private Environment environment;
    
    Logger logger = LoggerFactory.getLogger(this.getClass());
    
    Map<String, String> result = new HashMap<>();
    
    //SEND메일
    public void mailSend(String cmpnCd, String mailSubject, String subSubject, StringBuffer mailContent, String sendUser, String recvAddress){

    	String[] activeProfiles = environment.getActiveProfiles();
    	//local 환경에선 메일 전송 불가
		if(activeProfiles[0].equals("local")) {
			//sendEmail(cmpnCd, recvAddress, sendUser, mailSubject, subSubject, mailContent);
			return;
		}
		//개발환경 메일 세팅
		if(activeProfiles[0].equals("dev")) {
			//recvAddress = "";
			return;
		}
    	
    	try{
    		// cmpnCd : 회사코드,  recvAddress : 받는이이메일주소, sendUser : 답변자사번, mailSubject : 메일제목,  subSubject : 메일소제목, mailContent : 메일내용
			sendEmail(cmpnCd, recvAddress, sendUser, mailSubject, subSubject, mailContent);
			//storage.addObject("mailSendMsg", "");
		}catch(Exception e) {
			//storage.addObject("mailSendMsg", "메일전송에 실패하였습니다.");
        	//storage.setMessage("udap.common.mail.MailSend 매일전송실패.\\n" + e.getMessage());
        }
		
    }
    
    // cmpnCd : 회사코드,  mailSubject : 메일제목,  subSubject : 메일소제목, mailContent : 메일내용,  sendUser : 답변자사번, recvAddress : 받는이이메일주소
    public void sendEmail(String cmpnCd, String toEmail, String sendUser, String mailSubject, String subSubject, StringBuffer mailContent) {
    	
    	Date today=new Date();
        SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd");       
        String date = formater.format(today);			//오늘날짜										
        
        Mail mail = new Mail();												
        mail.setCmpnCd(cmpnCd);							//회사코드
        mail.setEmpNo(sendUser);						//답변자사번번호
        
        List<EasyHashMap<String, Object>> mailInfo = mailMapper.selectMailCommList(mail);		//메일 INFO
        List<EasyHashMap<String, Object>> userInfo = mailMapper.selectMailUserList(mail);		//답변자 INFO

        String smtpIp 	= (String) mailInfo.get(0).get("esbsCd1");		// 메일서버 주소 설정
		String smtpUser = (String) mailInfo.get(0).get("esbsCd2");		// SMTP인증 아이디
		String smtpPw 	= (String) mailInfo.get(0).get("esbsCd3");		// SMTP인증 비밀번호
		String link 	= (String) mailInfo.get(0).get("esbsCd4");		// 링크
		String cmpn 	= (String) mailInfo.get(0).get("esbsCd5");		// 회사구분
        
        String fromEmail = "";
		String fromName = "";
		String fromDuty = "";
		String fromDept = "";
		String fromTel = "";
		
		if(sendUser.equals("hradmin@sgc.co.kr")){
			fromEmail = "hradmin@sgc.co.kr";
			fromName = "SGC포탈 시스템 관리자";
			fromDuty = "";
			fromDept = "본사";
			fromTel = "02-489-9000";
		}else{
			fromEmail = (String) userInfo.get(0).get("eMail");						//FROM 이메일주소
			fromName = (String) userInfo.get(0).get("empNm");						//FROM 사원명
			fromDuty = (String) userInfo.get(0).get("aDuty");						//FROM 직급
			fromDept = (String) userInfo.get(0).get("departDeptNm");				//FROM 부서
			fromTel = (String) userInfo.get(0).get("phone");						//FROM 전화번호
		}		
			
		Properties properties = new Properties();									// Properties 객체 설정
		properties.put("mail.transport.protocol", "smtp");							// SMTP 프로토콜 사용
		properties.put("mail.smtp.host", smtpIp);									// 메일서버 주소 설정
		properties.put("mail.smtp.port", "25");										// 메일서버 포트 설정
		properties.put("mail.smtp.auth", true);										// 인증 사용 여부
		
		SmtpAuth auth = new SmtpAuth(smtpUser, smtpPw);								// SMTP 인증을 위해서 반드시 필요하다
		
		StringBuffer contentBase = new StringBuffer();								// 메일양식 
		contentBase.append(" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>                                                                                                                                                                                                      \n");
		contentBase.append(" <html xmlns='http://www.w3.org/1999/xhtml'>                                                                                                                                                                                                     \n");
		contentBase.append(" <head> \n");
		contentBase.append(" <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> \n");
		contentBase.append(" <title>SGC이앤씨</title> \n");
		contentBase.append(" </head> \n");
		contentBase.append(" <body> \n");
		contentBase.append(" <div style='padding:10px; border:#CCC solid 1px;'>                                                                                                                                                                                                            \n");
		contentBase.append(" <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                               \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td height='72'>                                                                                                                                                                                                                                          \n");
		contentBase.append("     <table  border='0' cellpadding='0' cellspacing='0' background='"+link+"/resources/images/mail/top_bg.gif' style='width:100%; background-repeat:repeat-x;'>                                                                                                                 \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td height='72' align='left' valign='top'><img src='"+link+"/resources/images/mail/top_logo_"+cmpn+".gif' width='187' height='72' alt='SGC이앤씨' /></td>                                                                                                                            \n");
		contentBase.append("         <td width='100%'>&nbsp;</td>                                                                                                                                                                                                                          \n");
		contentBase.append("         <td align='right' valign='top'></td>                                                                                                                                                           \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("     </table></td>                                                                                                                                                                                                                                             \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td style='padding:20px;'>                                                                                                                                                                                                                                \n");
		contentBase.append("      <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                          \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td width='19' height='46'><img src='"+link+"/resources/images/mail/content_l_01.gif' width='19' height='46' alt='' /></td>                                                                                                                                                             \n");
//		contentBase.append("         <td width='100%' style=' background-image:url("+link+"/resources/images/mail/content_c.gif); background-repeat:repeat-x; font-family:돋움; font-size:12px; color:#ffffff; text-align:left;'>                                                                                    \n");
		contentBase.append("         <td width='100%' background='"+link+"/resources/images/mail/content_c.gif' style='background-repeat:repeat-x; font-family:맑은 고딕; font-size:12px; color:#ffffff; text-align:left;'>                                                                                    \n");
		contentBase.append("          <table border='0' cellpadding='0' cellspacing='0' style='width:100%'>                                                                                                                                                                                      \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("            <td style='color:#ffffff;'>안녕하세요. <strong>"+fromDept+"  "+fromName+"</strong> 입니다.</td>                                                                                                                                                                                       \n");
		contentBase.append("            <td align='right' style='color:#ffffff;'>"+date+"</td>                                                                                                                                                                                                                  \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("          </table>                                                                                                                                                                                                                                             \n");
		contentBase.append("         </td>                                                                                                                                                                                                                                                 \n");
		contentBase.append("         <td width='19'><img src='"+link+"/resources/images/mail/content_r_01.gif' width='19' height='46' alt='' /></td>                                                                                                                                                                         \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td height='38'><img src='"+link+"/resources/images/mail/content_l_02.gif' width='19' height='38' alt='' /></td>                                                                                                                                                                        \n");
		contentBase.append("         <td style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; color:#5274ea; text-align:left; line-height:20px;'><strong>"+subSubject+"</strong> 관련하여 메일 보내드리오니 확인  바랍니다. </td>                        \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_02.gif' width='19' height='38' alt='' /></td>                                                                                                                                                                                    \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style=' background-repeat:repeat-y;'>&nbsp;</td>                                                                                        \n");
		contentBase.append("         <td  style=' background-repeat:repeat-y; padding-top:20px; padding-bottom:20px; line-height:20px;'><strong style='font-size:12px; color:#5274ea; font-family:맑은 고딕;'>"+mailContent+"</strong></td>          \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                            \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style='background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                      \n");
		contentBase.append("         <td align='center' valign='middle' style='padding-top:15px; padding-bottom:15px; border-top:#CCC solid 1px;'><a href='https://portal.sgc.co.kr/websquare/'><img src='"+link+"/resources/images/mail/btn_site.gif' alt='사이트접속하기' width='145' height='28' border='0' /></a></td>                              \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                     \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_l_04.gif' width='19' height='128' alt='' /></td>                                                                                                                                                                                   \n");
		contentBase.append("         <td align='left' valign='top' background='"+link+"/resources/images/mail/sign_c.gif' style='background-repeat:repeat-x; text-align:left'>                                                                                                                              \n");
		contentBase.append("          <table width='800' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                       \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td colspan='2'><img src='"+link+"/resources/images/mail/sign_logo_"+cmpn+".gif' width='300' height='50' alt='We build your dream SGC이앤씨' /></td>                                                                                                                             \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                             \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22' align='center' valign='middle'><img src='"+link+"/resources/images/mail/sign_icon.gif' width='13' height='13' alt='' /></td>                                                                                                                             \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>"+fromDept+"&nbsp;&nbsp;&nbsp;"+fromDuty+"&nbsp;&nbsp;"+fromName+"</td>                                                                        \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                                                                                                            \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>전화 : "+fromTel+"&nbsp;&nbsp;&nbsp;</td>                                                                                           \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                                                                                                            \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>E-Mail : "+fromEmail+"</td>                                                                                                    \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("                                                                                                                                                                                                                                                               \n");
		contentBase.append("         </table></td>                                                                                                                                                                                                                                         \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_04.gif' width='19' height='128' alt='' /></td>                                                                                                                                                                                   \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("     </table></td>                                                                                                                                                                                                                                             \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td align='left' valign='bottom' bgcolor='#CCCCCC'><img src='"+link+"/resources/images/mail/copy.gif' width='291' height='28' alt='' /></td>                                                                                                                                                \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append(" </table>                                                                                                                                                                                                                                                      \n");
		contentBase.append(" </div>                                                                                                                                                                                                                                                        \n");
		contentBase.append(" </body> \n");
		contentBase.append(" </html>                                                                                                                                                                                                                                                        \n");
    
		try {
			
			Session session = Session.getInstance(properties, auth);				// Properties 객체와 (인증)auth객체로 메일전송 세션 생성
			MimeMessage msg = new MimeMessage(session);								// 메일 객체를 세션을 통해 생성
			
			InternetAddress[] to_address = {new InternetAddress(toEmail)};			// 받는 사람 메일 주소 객체 생성
			msg.setFrom(new InternetAddress(fromEmail));							// 보내는 사람 메일주소 설정
			msg.setRecipients(Message.RecipientType.TO, to_address);				// 받는 사람 메일 주소를 메일 객체에 매핑
			msg.setContent(contentBase.toString(), "text/html; charset=utf-8");		// 메일 내용을 설정하며 메일 형식을 HTML로 지정
			msg.setSubject(mailSubject,"utf-8");									// 메일 제목 설정
			msg.setSentDate(new Date());											// 보내는 날짜 설정
			System.out.print(msg.getContent());
			Transport.send(msg);													// 메일 전송 부분
			
		} catch(MessagingException me) {
			//WAFLogger.error(this.getClass().getName() + " --> sendEmail() : \n" + me.getMessage());
			//WAFLogger.error(me);
			//throw me;
		} catch(Exception e) {
			//WAFLogger.error(this.getClass().getName() + " --> sendEmail() : \n" + e.getMessage());
			//WAFLogger.error(e);
			//throw e;
		}
    }
    
    public void mailSend2(String mailSubject, String subSubject, String cmpnCd, String empNo, String empNm, String jobGradeNm, String deptNm, String recvAddress, String staDate, String endDate, String dtmNm, String staDateResult, String contents){
    	
    	String[] activeProfiles = environment.getActiveProfiles();
    	
    	//local 환경에선 메일 전송 불가
		if(activeProfiles[0].equals("local")) {
			logger.info("[MYTEST] test batch {}", recvAddress);
			return;
		}
		//개발환경 메일 세팅
		if(activeProfiles[0].equals("dev")) {
			recvAddress = "테스트메일";
			return;
		}
    	
    	try{
    		sendEmail2(cmpnCd, recvAddress, mailSubject, subSubject, empNo, empNm, jobGradeNm, deptNm, staDate, endDate, dtmNm, staDateResult, contents);	
		}catch(Exception e) {
			
        }
		
    }
    
    /**
	 * 이메일 전송 메소드(Javamail 사용)
	 * @param user
	 * @param from_email
	 * @param to_name
	 * @param to_email
	 */
    public void sendEmail2(String cmpnCd, String toEmail, String mailSubject, String subSubject, String empNo, String empNm, String jobGradeNm, String deptNm, String staDate, String endDate, String dtmNm, String staDateResult, String contents) throws Exception{
		
    	Date today=new Date();
        SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd");       
        String date = formater.format(today);
        
        Mail mail = new Mail();												
        mail.setCmpnCd(cmpnCd);
        
        List<EasyHashMap<String, Object>> mailInfo = mailMapper.selectMailCommList(mail);		//메일 INFO

        String smtpIp 	= (String) mailInfo.get(0).get("esbsCd1");		// 메일서버 주소 설정
		String smtpUser = (String) mailInfo.get(0).get("esbsCd2");		// SMTP인증 아이디
		String smtpPw 	= (String) mailInfo.get(0).get("esbsCd3");		// SMTP인증 비밀번호
		String link 	= (String) mailInfo.get(0).get("esbsCd4");		// 링크
		String cmpn 	= (String) mailInfo.get(0).get("esbsCd5");		// 회사구분
		
		String fromEmail = "hradmin@sgc.co.kr";
		String fromName = "SGC포탈시스템 관리자";
		String fromDuty = "SGC포탈시스템 관리자";
		String fromDept = "본사";
		String fromTel = "02-489-9000";
		
		Properties properties = new Properties();									// Properties 객체 설정
		properties.put("mail.transport.protocol", "smtp");							// SMTP 프로토콜 사용
		properties.put("mail.smtp.host", smtpIp);									// 메일서버 주소 설정
		properties.put("mail.smtp.port", "25");										// 메일서버 포트 설정
		properties.put("mail.smtp.auth", true);										// 인증 사용 여부
		
		SmtpAuth auth = new SmtpAuth(smtpUser, smtpPw);								// SMTP 인증을 위해서 반드시 필요하다

		StringBuffer contentBase = new StringBuffer();
		contentBase.append(" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>                                                                                                                                                                                                      \n");
		contentBase.append(" <html xmlns='http://www.w3.org/1999/xhtml'>                                                                                                                                                                                                     \n");
		contentBase.append(" <head> \n");
		contentBase.append(" <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> \n");
		contentBase.append(" <title>SGC이앤씨</title> \n");
		contentBase.append(" </head> \n");
		contentBase.append(" <body> \n");
		contentBase.append(" <div style='padding:10px; border:#CCC solid 1px;'>                                                                                                                                                                                                            \n");
		contentBase.append(" <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                               \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td height='72'>                                                                                                                                                                                                                                          \n");
		contentBase.append("     <table  border='0' cellpadding='0' cellspacing='0' background='"+link+"/resources/images/mail/top_bg.gif' style='width:100%; background-repeat:repeat-x;'>                                                                                                                 \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td height='72' align='left' valign='top'><img src='"+link+"/resources/images/mail/top_logo_"+cmpn+".gif' width='187' height='72' alt='SGC이앤씨' /></td>                                                                                                                            \n");
		contentBase.append("         <td width='100%'>&nbsp;</td>                                                                                                                                                                                                                          \n");
		contentBase.append("         <td align='right' valign='top'></td>                                                                                                                                                           \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("     </table></td>                                                                                                                                                                                                                                             \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td style='padding:20px;'>                                                                                                                                                                                                                                \n");
		contentBase.append("      <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                          \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td width='19' height='46'><img src='"+link+"/resources/images/mail/content_l_01.gif' width='19' height='46' alt='' /></td>                                                                                                                                                             \n");
//		contentBase.append("         <td width='100%' style=' background-image:url("+link+"/resources/images/mail/content_c.gif); background-repeat:repeat-x; font-family:돋움; font-size:12px; color:#ffffff; text-align:left;'>                                                                                    \n");
		contentBase.append("         <td width='100%' background='"+link+"/resources/images/mail/content_c.gif' style='background-repeat:repeat-x; font-family:맑은 고딕; font-size:12px; color:#ffffff; text-align:left;'>                                                                                    \n");
		contentBase.append("          <table border='0' cellpadding='0' cellspacing='0' style='width:100%'>                                                                                                                                                                                      \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
//		contentBase.append("            <td style='color:#ffffff;'>안녕하세요. <strong>"+fromDept+"  "+fromName+"</strong> 입니다.</td>                                                                                                                                                                                       \n");
		contentBase.append("            <td style='color:#ffffff;'></td>                                                                                                                                                                                       \n");
		contentBase.append("            <td align='right' style='color:#ffffff;'>"+date+"</td>                                                                                                                                                                                                                  \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("          </table>                                                                                                                                                                                                                                             \n");
		contentBase.append("         </td>                                                                                                                                                                                                                                                 \n");
		contentBase.append("         <td width='19'><img src='"+link+"/resources/images/mail/content_r_01.gif' width='19' height='46' alt='' /></td>                                                                                                                                                                         \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td height='38'><img src='"+link+"/resources/images/mail/content_l_02.gif' width='19' height='38' alt='' /></td>                                                                                                                                                                        \n");
		contentBase.append("         <td style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; color:#5274ea; text-align:left; line-height:20px;'><strong>"+subSubject+"</strong> 관련하여 사전 안내드립니다. </td>                        \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_02.gif' width='19' height='38' alt='' /></td>                                                                                                                                                                                    \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
//		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
//		contentBase.append("          <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style=' background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                \n");
//		contentBase.append("         <td  style=' background-repeat:repeat-y; padding-top:20px; padding-bottom:20px; font-size:12px; color:#5274ea; font-family:맑은 고딕; line-height:20px;'><pre><strong>"+mailContent+"</string></pre></td>                                                                                                                     \n");
//		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                            \n");
//		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("          <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style=' background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                \n");
		contentBase.append("         <td  style=' background-repeat:repeat-y; padding-top:20px; padding-bottom:20px; font-size:12px; color:#5274ea; font-family:맑은 고딕; line-height:20px;'><pre>				\n");
		contentBase.append("			<table width='600' border='1' cellpadding='1' cellspacing='1'>			\n");
		contentBase.append("			<tr>																	\n");
		contentBase.append("				<td colspan='4' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'><strong>인적사항</strong></td>											\n");
		contentBase.append("			</tr>																	\n");
		contentBase.append("			<tr>																	\n");
		contentBase.append("				<td width='10%' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>사번</td>											\n");
		contentBase.append("				<td width='40%' align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>"+empNo+"</td>												\n");
		contentBase.append("				<td width='10%' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>소속</td>											\n");
		contentBase.append("				<td width='40%' align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>"+deptNm+"</td>												\n");
		contentBase.append("			</tr>																	\n");
		contentBase.append("			<tr>																	\n");
		contentBase.append("				<td width='10%' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>직위</td>											\n");
		contentBase.append("				<td width='40%' align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>"+jobGradeNm+"</td>												\n");
		contentBase.append("				<td width='10%' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>성명</td>											\n");
		contentBase.append("				<td width='40%' align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>"+empNm+"</td>												\n");
		contentBase.append("			</tr>																	\n");
		contentBase.append("			<tr>																	\n");
		contentBase.append("				<td colspan='4' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'><strong>휴가신청사항</strong></td>										\n");
		contentBase.append("			</tr>																	\n");
		contentBase.append("			<tr>																	\n");
		contentBase.append("				<td width='50%' colspan='2' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>일정</td>								\n");
		contentBase.append("				<td width='50%' colspan='2' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>휴가유형</td>								\n");
		contentBase.append("			</tr>																	\n");
		contentBase.append("			<tr>																	\n");
		contentBase.append("				<td width='50%' colspan='2' align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>"+staDate+" ~ "+endDate+"</td>									\n");
		contentBase.append("				<td width='50%' colspan='2' align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>"+dtmNm+"</td>									\n");
		contentBase.append("			</tr>																	\n");
		contentBase.append("			</table>																\n");
		contentBase.append("			\n"+contents+"				\n");
		contentBase.append("		 </pre></td>                                                                \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                            \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style='background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                      \n");
		contentBase.append("         <td align='center' valign='middle' style='padding-top:15px; padding-bottom:15px; border-top:#CCC solid 1px;'><a href='https://portal.sgc.co.kr/websquare/'><img src='"+link+"/resources/images/mail/btn_site.gif' alt='사이트접속하기' width='145' height='28' border='0' /></a></td>                              \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                     \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_l_04.gif' width='19' height='128' alt='' /></td>                                                                                                                                                                                   \n");
		contentBase.append("         <td align='left' valign='top' background='"+link+"/resources/images/mail/sign_c.gif' style='background-repeat:repeat-x; text-align:left'>                                                                                                                              \n");
		contentBase.append("          <table width='800' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                       \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td colspan='2'><img src='"+link+"/resources/images/mail/sign_logo_"+cmpn+".gif' width='300' height='50' alt='We build your dream SGC이앤씨' /></td>                                                                                                                             \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                             \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22' align='center' valign='middle'><img src='"+link+"/resources/images/mail/sign_icon.gif' width='13' height='13' alt='' /></td>                                                                                                                             \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>"+fromDept+"&nbsp;&nbsp;&nbsp;"+fromDuty+"&nbsp;&nbsp;"+fromName+"</td>                                                                        \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                                                                                                            \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>전화 : "+fromTel+"&nbsp;&nbsp;&nbsp;</td>                                                                                           \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                                                                                                            \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>E-Mail : "+fromEmail+"</td>                                                                                                    \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("                                                                                                                                                                                                                                                               \n");
		contentBase.append("         </table></td>                                                                                                                                                                                                                                         \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_04.gif' width='19' height='128' alt='' /></td>                                                                                                                                                                                   \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("     </table></td>                                                                                                                                                                                                                                             \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td align='left' valign='bottom' bgcolor='#CCCCCC'><img src='"+link+"/resources/images/mail/copy.gif' width='291' height='28' alt='' /></td>                                                                                                                                                \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append(" </table>                                                                                                                                                                                                                                                      \n");
		contentBase.append(" </div>                                                                                                                                                                                                                                                        \n");
		contentBase.append(" </body> \n");
		contentBase.append(" </html>                                                                                                                                                                                                                                                        \n");
		
		try {
			
			Session session = Session.getInstance(properties, auth);				// Properties 객체와 auth(인증)객체로 메일전송 세션 생성
			MimeMessage msg = new MimeMessage(session);								// 메일 객체를 세션을 통해 생성
			
			InternetAddress[] to_address = {new InternetAddress(toEmail)};			// 받는 사람 메일 주소 객체 생성
			
			InternetAddress addr = new InternetAddress();  
			addr.setPersonal(fromName,"UTF-8");  
			addr.setAddress(fromEmail);
			
			msg.setFrom(addr);							// 보내는 사람 메일주소 설정
			
			msg.setRecipients(Message.RecipientType.TO, to_address);				// 받는 사람 메일 주소를 메일 객체에 매핑
			msg.setContent(contentBase.toString(), "text/html; charset=utf-8");					// 메일 내용을 설정하며 메일 형식을 HTML로 지정
			msg.setSubject(mailSubject,"utf-8");									// 메일 제목 설정
			msg.setSentDate(new Date());											// 보내는 날짜 설정
			
			Transport.send(msg);													// 메일 전송 부분
			
		} catch(MessagingException me) {
		} catch(Exception e) {
		}
	}
    

    
    public void mailSend3(String mailSubject, String subSubject, String cmpnCd, String empNo, String empNm, String recvAddress, String contents, String contents2){
    	
    	String[] activeProfiles = environment.getActiveProfiles();
    	
    	//local 환경에선 메일 전송 불가
		if(activeProfiles[0].equals("local")) {
			logger.info("[MYTEST] test batch {}", recvAddress);
			return;
		}
		//개발환경 메일 세팅
		if(activeProfiles[0].equals("dev")) {
			//recvAddress = "테스트메일";
			recvAddress = "park.sh@sgc.co.kr";
			return;
		}
    	
    	try{
    		sendEmail3(cmpnCd, recvAddress, mailSubject, subSubject, empNo, empNm, contents, contents2);	
		}catch(Exception e) {
			
        }
		
    }
    
    /**
	 * 이메일 전송 메소드(Javamail 사용)
	 * @param user
	 * @param from_email
	 * @param to_name
	 * @param to_email
	 */
    public void sendEmail3(String cmpnCd, String toEmail, String mailSubject, String subSubject, String empNo, String empNm, String contents, String contents2) throws Exception{
		
    	Date today=new Date();
        SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd");       
        String date = formater.format(today);
        
        Mail mail = new Mail();												
        mail.setCmpnCd(cmpnCd);
        
        List<EasyHashMap<String, Object>> mailInfo = mailMapper.selectMailCommList(mail);		//메일 INFO

        String smtpIp 	= (String) mailInfo.get(0).get("esbsCd1");		// 메일서버 주소 설정
		String smtpUser = (String) mailInfo.get(0).get("esbsCd2");		// SMTP인증 아이디
		String smtpPw 	= (String) mailInfo.get(0).get("esbsCd3");		// SMTP인증 비밀번호
		String link 	= (String) mailInfo.get(0).get("esbsCd4");		// 링크
		String cmpn 	= (String) mailInfo.get(0).get("esbsCd5");		// 회사구분
		
		String fromEmail = "hradmin@sgc.co.kr";
		String fromName = "SGC포탈 시스템 관리자";
		String fromDuty = "";
		String fromDept = "본사";
		String fromTel = "02-489-9000";
		
		Properties properties = new Properties();									// Properties 객체 설정
		properties.put("mail.transport.protocol", "smtp");							// SMTP 프로토콜 사용
		properties.put("mail.smtp.host", smtpIp);									// 메일서버 주소 설정
		properties.put("mail.smtp.port", "25");										// 메일서버 포트 설정
		properties.put("mail.smtp.auth", true);										// 인증 사용 여부
		
		SmtpAuth auth = new SmtpAuth(smtpUser, smtpPw);								// SMTP 인증을 위해서 반드시 필요하다

		StringBuffer contentBase = new StringBuffer();
		contentBase.append(" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>                                                                                                                                                                                                      \n");
		contentBase.append(" <html xmlns='http://www.w3.org/1999/xhtml'>                                                                                                                                                                                                     \n");
		contentBase.append(" <head> \n");
		contentBase.append(" <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> \n");
		contentBase.append(" <title>SGC이앤씨</title> \n");
		contentBase.append(" </head> \n");
		contentBase.append(" <body> \n");
		contentBase.append(" <div style='padding:10px; border:#CCC solid 1px;'>                                                                                                                                                                                                            \n");
		contentBase.append(" <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                               \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td height='72'>                                                                                                                                                                                                                                          \n");
		contentBase.append("     <table  border='0' cellpadding='0' cellspacing='0' background='"+link+"/resources/images/mail/top_bg.gif' style='width:100%; background-repeat:repeat-x;'>                                                                                                                 \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td height='72' align='left' valign='top'><img src='"+link+"/resources/images/mail/top_logo_"+cmpn+".gif' width='187' height='72' alt='SGC이앤씨' /></td>                                                                                                                            \n");
		contentBase.append("         <td width='100%'>&nbsp;</td>                                                                                                                                                                                                                          \n");
		contentBase.append("         <td align='right' valign='top'></td>                                                                                                                                                           \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("     </table></td>                                                                                                                                                                                                                                             \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td style='padding:20px;'>                                                                                                                                                                                                                                \n");
		contentBase.append("      <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                          \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td width='19' height='46'><img src='"+link+"/resources/images/mail/content_l_01.gif' width='19' height='46' alt='' /></td>                                                                                                                                                             \n");
//		contentBase.append("         <td width='100%' style=' background-image:url("+link+"/resources/images/mail/content_c.gif); background-repeat:repeat-x; font-family:돋움; font-size:12px; color:#ffffff; text-align:left;'>                                                                                    \n");
		contentBase.append("         <td width='100%' background='"+link+"/resources/images/mail/content_c.gif' style='background-repeat:repeat-x; font-family:맑은 고딕; font-size:12px; color:#ffffff; text-align:left;'>                                                                                    \n");
		contentBase.append("          <table border='0' cellpadding='0' cellspacing='0' style='width:100%'>                                                                                                                                                                                      \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
//		contentBase.append("            <td style='color:#ffffff;'>안녕하세요. <strong>"+fromDept+"  "+fromName+"</strong> 입니다.</td>                                                                                                                                                                                       \n");
		contentBase.append("            <td style='color:#ffffff;'></td>                                                                                                                                                                                       \n");
		contentBase.append("            <td align='right' style='color:#ffffff;'>"+date+"</td>                                                                                                                                                                                                                  \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("          </table>                                                                                                                                                                                                                                             \n");
		contentBase.append("         </td>                                                                                                                                                                                                                                                 \n");
		contentBase.append("         <td width='19'><img src='"+link+"/resources/images/mail/content_r_01.gif' width='19' height='46' alt='' /></td>                                                                                                                                                                         \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td height='38'><img src='"+link+"/resources/images/mail/content_l_02.gif' width='19' height='38' alt='' /></td>                                                                                                                                                                        \n");
		contentBase.append("         <td style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; color:#5274ea; text-align:left; line-height:20px;'><strong>"+subSubject+"</strong> 관련하여 사전 안내드립니다. </td>                        \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_02.gif' width='19' height='38' alt='' /></td>                                                                                                                                                                                    \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("          <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style=' background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                \n");
		contentBase.append("         <td  style=' background-repeat:repeat-y; padding-top:20px; padding-bottom:20px; line-height:20px;'><strong style='font-size:12px; color:#5274ea; font-family:맑은 고딕;'>"+contents+"</strong></td>          \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                            \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("          <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style=' background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                \n");
		contentBase.append("         <td  style=' background-repeat:repeat-y; padding-top:20px; padding-bottom:20px; font-size:12px; color:#5274ea; font-family:맑은 고딕; line-height:20px;'><pre>				\n");
		contentBase.append("			<table width='600' border='1' cellpadding='1' cellspacing='1'>			\n");
		contentBase.append("			<tr>																	\n");
		contentBase.append("				<td width='15%' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'><strong>구분</strong></td>											\n");
		contentBase.append("				<td width='10%' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'><strong>관계</strong></td>											\n");
		contentBase.append("				<td width='7%' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'><strong>휴가</strong></td>											\n");
		contentBase.append("				<td width='10%' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'><strong>경조비(원)</strong></td>										\n");
		contentBase.append("				<td width='7%' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'><strong>화환</strong></td>											\n");
		contentBase.append("				<td width='10%' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'><strong>증빙서류</strong></td>										\n");
		contentBase.append("			</tr>																	\n");
		contentBase.append("			<tr>																	\n");
		contentBase.append("				<td rowspan='3' align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>회갑 (만60세)<br>고희 (만 69세)</td>											\n");
		contentBase.append("				<td align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>본인, 배우자</td>																	\n");
		contentBase.append("				<td align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>1일</td>																			\n");
		contentBase.append("				<td align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>200,000</td>																		\n");
		contentBase.append("				<td rowspan='3' align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>지급</td>																\n");
		contentBase.append("				<td rowspan='3' align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>가족관계 증명서</td>														\n");
		contentBase.append("			</tr>																	\n");
		contentBase.append("			<tr>																	\n");
		contentBase.append("				<td align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>부모</td>																			\n");
		contentBase.append("				<td align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>-</td>																			\n");
		contentBase.append("				<td align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>200,000</td>																		\n");
		contentBase.append("			</tr>																	\n");
		contentBase.append("			<tr>																	\n");
		contentBase.append("				<td align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>배우자 부모</td>																		\n");
		contentBase.append("				<td align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>-</td>																			\n");
		contentBase.append("				<td align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>200,000</td>																		\n");
		contentBase.append("			</tr>																	\n");
		contentBase.append("			</table>																\n");
		contentBase.append("		 </pre></td>                                                                \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                            \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");

		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("          <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style=' background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                \n");
		contentBase.append("         <td  style=' background-repeat:repeat-y; padding-top:20px; padding-bottom:20px; line-height:20px;'><strong style='font-size:12px; color:#5274ea; font-family:맑은 고딕;'>"+contents2+"</strong></td>                                                                                                                     \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                            \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style='background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                      \n");
		contentBase.append("         <td align='center' valign='middle' style='padding-top:15px; padding-bottom:15px; border-top:#CCC solid 1px;'><a href='https://portal.sgc.co.kr/websquare/'><img src='"+link+"/resources/images/mail/btn_site.gif' alt='사이트접속하기' width='145' height='28' border='0' /></a></td>                              \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                     \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_l_04.gif' width='19' height='128' alt='' /></td>                                                                                                                                                                                   \n");
		contentBase.append("         <td align='left' valign='top' background='"+link+"/resources/images/mail/sign_c.gif' style='background-repeat:repeat-x; text-align:left'>                                                                                                                              \n");
		contentBase.append("          <table width='800' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                       \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td colspan='2'><img src='"+link+"/resources/images/mail/sign_logo_"+cmpn+".gif' width='300' height='50' alt='We build your dream SGC이앤씨' /></td>                                                                                                                             \n");
		contentBase.append("             </tr>                                                                                                                                                                                                                                             \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");		
		contentBase.append("             <td width='36' height='22' align='center' valign='middle'><img src='"+link+"/resources/images/mail/sign_icon.gif' width='13' height='13' alt='' /></td>                                                                                                                             \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>"+fromDept+"&nbsp;&nbsp;&nbsp;"+fromDuty+"&nbsp;&nbsp;"+fromName+"</td>                                                                        \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                                                                                                            \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>전화 : "+fromTel+"&nbsp;&nbsp;&nbsp;</td>                                                                                           \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                                                                                                            \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>E-Mail : "+fromEmail+"</td>                                                                                                    \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("                                                                                                                                                                                                                                                               \n");
		contentBase.append("         </table></td>                                                                                                                                                                                                                                         \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_04.gif' width='19' height='128' alt='' /></td>                                                                                                                                                                                   \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("     </table></td>                                                                                                                                                                                                                                             \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td align='left' valign='bottom' bgcolor='#CCCCCC'><img src='"+link+"/resources/images/mail/copy.gif' width='291' height='28' alt='' /></td>                                                                                                                                                \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append(" </table>                                                                                                                                                                                                                                                      \n");
		contentBase.append(" </div>                                                                                                                                                                                                                                                        \n");
		contentBase.append(" </body> \n");
		contentBase.append(" </html>                                                                                                                                                                                                                                                        \n");
		
		try {
			
			Session session = Session.getInstance(properties, auth);				// Properties 객체와 auth(인증)객체로 메일전송 세션 생성
			MimeMessage msg = new MimeMessage(session);								// 메일 객체를 세션을 통해 생성
			
			InternetAddress[] to_address = {new InternetAddress(toEmail)};			// 받는 사람 메일 주소 객체 생성
			
			InternetAddress addr = new InternetAddress();  
			addr.setPersonal(fromName,"UTF-8");  
			addr.setAddress(fromEmail);
			
			msg.setFrom(addr);							// 보내는 사람 메일주소 설정
			
			msg.setRecipients(Message.RecipientType.TO, to_address);				// 받는 사람 메일 주소를 메일 객체에 매핑
			msg.setContent(contentBase.toString(), "text/html; charset=utf-8");					// 메일 내용을 설정하며 메일 형식을 HTML로 지정
			msg.setSubject(mailSubject,"utf-8");									// 메일 제목 설정
			msg.setSentDate(new Date());											// 보내는 날짜 설정
			
			Transport.send(msg);													// 메일 전송 부분
			
		} catch(MessagingException me) {
		} catch(Exception e) {
		}
	}
    

    //SEND메일
    public void mailSend4(String cmpnCd, String mailSubject, String subSubject, StringBuffer mailContent, String sendUser, String recvAddress){

    	String[] activeProfiles = environment.getActiveProfiles();
    	//local 환경에선 메일 전송 불가
		if(activeProfiles[0].equals("local")) {
			//sendEmail4(cmpnCd, recvAddress, sendUser, mailSubject, subSubject, mailContent);
			return;
		}
		//개발환경 메일 세팅
		if(activeProfiles[0].equals("dev")) {
			recvAddress = "park.sh@sgc.co.kr";
			return;
		}
    	
    	try{
    		// cmpnCd : 회사코드,  mailSubject : 메일제목,  subSubject : 메일소제목, mailContent : 메일내용,  sendUser : 답변자사번, recvAddress : 받는이이메일주소
			sendEmail4(cmpnCd, recvAddress, sendUser, mailSubject, subSubject, mailContent);
			//storage.addObject("mailSendMsg", "");
		}catch(Exception e) {
			//storage.addObject("mailSendMsg", "메일전송에 실패하였습니다.");
        	//storage.setMessage("udap.common.mail.MailSend 매일전송실패.\\n" + e.getMessage());
        }
		
    }
    
    // cmpnCd : 회사코드,  mailSubject : 메일제목,  subSubject : 메일소제목, mailContent : 메일내용,  sendUser : 답변자사번, recvAddress : 받는이이메일주소
    public void sendEmail4(String cmpnCd, String toEmail, String sendUser, String mailSubject, String subSubject, StringBuffer mailContent) {
    	
    	Date today=new Date();
        SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd");       
        String date = formater.format(today);			//오늘날짜										
        
        Mail mail = new Mail();												
        mail.setCmpnCd(cmpnCd);							//회사코드
        mail.setEmpNo(sendUser);						//답변자사번번호
        
        List<EasyHashMap<String, Object>> mailInfo = mailMapper.selectMailCommList(mail);		//메일 INFO

        String smtpIp 	= (String) mailInfo.get(0).get("esbsCd1");		// 메일서버 주소 설정
		String smtpUser = (String) mailInfo.get(0).get("esbsCd2");		// SMTP인증 아이디
		String smtpPw 	= (String) mailInfo.get(0).get("esbsCd3");		// SMTP인증 비밀번호
		String link 	= (String) mailInfo.get(0).get("esbsCd4");		// 링크
		String cmpn 	= (String) mailInfo.get(0).get("esbsCd5");		// 회사구분
        
        String fromEmail = "hradmin@sgc.co.kr";
		String fromName = "성과평가 담당자";        
		String fromDuty = "";        
		String fromDept = "전략기획본부 기업문화팀";                
		String fromTel = "02-489-8333";        	
			
		Properties properties = new Properties();									// Properties 객체 설정
		properties.put("mail.transport.protocol", "smtp");							// SMTP 프로토콜 사용
		properties.put("mail.smtp.host", smtpIp);									// 메일서버 주소 설정
		properties.put("mail.smtp.port", "25");										// 메일서버 포트 설정
		properties.put("mail.smtp.auth", true);										// 인증 사용 여부
		
		SmtpAuth auth = new SmtpAuth(smtpUser, smtpPw);								// SMTP 인증을 위해서 반드시 필요하다
		
		StringBuffer contentBase = new StringBuffer();								// 메일양식 
		contentBase.append(" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>                                                                                                                                                                                                      \n");
		contentBase.append(" <html xmlns='http://www.w3.org/1999/xhtml'>                                                                                                                                                                                                     \n");
		contentBase.append(" <head> \n");
		contentBase.append(" <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> \n");
		contentBase.append(" <title>SGC이앤씨</title> \n");
		contentBase.append(" </head> \n");
		contentBase.append(" <body> \n");
		contentBase.append(" <div style='padding:10px; border:#CCC solid 1px;'>                                                                                                                                                                                                            \n");
		contentBase.append(" <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                               \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td height='72'>                                                                                                                                                                                                                                          \n");
		contentBase.append("     <table  border='0' cellpadding='0' cellspacing='0' background='"+link+"/resources/images/mail/top_bg.gif' style='width:100%; background-repeat:repeat-x;'>                                                                                                                 \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td height='72' align='left' valign='top'><img src='"+link+"/resources/images/mail/top_logo_"+cmpn+".gif' width='187' height='72' alt='SGC이앤씨' /></td>                                                                                                                            \n");
		contentBase.append("         <td width='100%'>&nbsp;</td>                                                                                                                                                                                                                          \n");
		contentBase.append("         <td align='right' valign='top'></td>                                                                                                                                                           \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("     </table></td>                                                                                                                                                                                                                                             \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td style='padding:20px;'>                                                                                                                                                                                                                                \n");
		contentBase.append("      <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                          \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td width='19' height='46'><img src='"+link+"/resources/images/mail/content_l_01.gif' width='19' height='46' alt='' /></td>                                                                                                                                                             \n");
//		contentBase.append("         <td width='100%' style=' background-image:url("+link+"/resources/images/mail/content_c.gif); background-repeat:repeat-x; font-family:돋움; font-size:12px; color:#ffffff; text-align:left;'>                                                                                    \n");
		contentBase.append("         <td width='100%' background='"+link+"/resources/images/mail/content_c.gif' style='background-repeat:repeat-x; font-family:맑은 고딕; font-size:12px; color:#ffffff; text-align:left;'>                                                                                    \n");
		contentBase.append("          <table border='0' cellpadding='0' cellspacing='0' style='width:100%'>                                                                                                                                                                                      \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("            <td style='color:#ffffff;'>안녕하세요. <strong>"+fromDept+"  "+fromName+"</strong> 입니다.</td>                                                                                                                                                                                       \n");
		contentBase.append("            <td align='right' style='color:#ffffff;'>"+date+"</td>                                                                                                                                                                                                                  \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("          </table>                                                                                                                                                                                                                                             \n");
		contentBase.append("         </td>                                                                                                                                                                                                                                                 \n");
		contentBase.append("         <td width='19'><img src='"+link+"/resources/images/mail/content_r_01.gif' width='19' height='46' alt='' /></td>                                                                                                                                                                         \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td height='38'><img src='"+link+"/resources/images/mail/content_l_02.gif' width='19' height='38' alt='' /></td>                                                                                                                                                                        \n");
		contentBase.append("         <td style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; color:#5274ea; text-align:left; line-height:20px;'><strong>"+subSubject+"</strong> 관련하여 메일 보내드리오니 확인  바랍니다. </td>                        \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_02.gif' width='19' height='38' alt='' /></td>                                                                                                                                                                                    \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style=' background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                \n");
		contentBase.append("         <td  style=' background-repeat:repeat-y; padding-top:20px; padding-bottom:20px; line-height:20px;'><strong style='font-size:12px; color:#5274ea; font-family:맑은 고딕;'>"+mailContent+"</strong></td>                                  \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                            \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style='background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                      \n");
		contentBase.append("         <td align='center' valign='middle' style='padding-top:15px; padding-bottom:15px; border-top:#CCC solid 1px;'><a href='https://portal.sgc.co.kr/websquare/'><img src='"+link+"/resources/images/mail/btn_site.gif' alt='사이트접속하기' width='145' height='28' border='0' /></a></td>                              \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                     \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_l_04.gif' width='19' height='128' alt='' /></td>                                                                                                                                                                                   \n");
		contentBase.append("         <td align='left' valign='top' background='"+link+"/resources/images/mail/sign_c.gif' style='background-repeat:repeat-x; text-align:left'>                                                                                                                              \n");
		contentBase.append("          <table width='800' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                       \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td colspan='2'><img src='"+link+"/resources/images/mail/sign_logo_"+cmpn+".gif' width='300' height='50' alt='We build your dream SGC이앤씨' /></td>                                                                                                                             \n");
		contentBase.append("             </tr>                                                                                                                                                                                                                                             \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22' align='center' valign='middle'><img src='"+link+"/resources/images/mail/sign_icon.gif' width='13' height='13' alt='' /></td>                                                                                                                             \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>"+fromDept+"&nbsp;&nbsp;&nbsp;"+fromDuty+"&nbsp;&nbsp;"+fromName+"</td>                                                                        \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                                                                                                            \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>전화 : "+fromTel+"&nbsp;&nbsp;&nbsp;</td>                                                                                           \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                                                                                                            \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>E-Mail : "+fromEmail+"</td>                                                                                                    \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("                                                                                                                                                                                                                                                               \n");
		contentBase.append("         </table></td>                                                                                                                                                                                                                                         \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_04.gif' width='19' height='128' alt='' /></td>                                                                                                                                                                                   \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("     </table></td>                                                                                                                                                                                                                                             \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td align='left' valign='bottom' bgcolor='#CCCCCC'><img src='"+link+"/resources/images/mail/copy.gif' width='291' height='28' alt='' /></td>                                                                                                                                                \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append(" </table>                                                                                                                                                                                                                                                      \n");
		contentBase.append(" </div>                                                                                                                                                                                                                                                        \n");
		contentBase.append(" </body> \n");
		contentBase.append(" </html>                                                                                                                                                                                                                                                        \n");
    
		try {
			
			Session session = Session.getInstance(properties, auth);				// Properties 객체와 (인증)auth객체로 메일전송 세션 생성
			MimeMessage msg = new MimeMessage(session);								// 메일 객체를 세션을 통해 생성
			
			InternetAddress[] to_address = {new InternetAddress(toEmail)};			// 받는 사람 메일 주소 객체 생성
			msg.setFrom(new InternetAddress(fromEmail));							// 보내는 사람 메일주소 설정
			msg.setRecipients(Message.RecipientType.TO, to_address);				// 받는 사람 메일 주소를 메일 객체에 매핑
			msg.setContent(contentBase.toString(), "text/html; charset=utf-8");		// 메일 내용을 설정하며 메일 형식을 HTML로 지정
			msg.setSubject(mailSubject,"utf-8");									// 메일 제목 설정
			msg.setSentDate(new Date());											// 보내는 날짜 설정
			System.out.print(msg.getContent());
			Transport.send(msg);													// 메일 전송 부분
			
		} catch(MessagingException me) {
			//WAFLogger.error(this.getClass().getName() + " --> sendEmail() : \n" + me.getMessage());
			//WAFLogger.error(me);
			//throw me;
		} catch(Exception e) {
			//WAFLogger.error(this.getClass().getName() + " --> sendEmail() : \n" + e.getMessage());
			//WAFLogger.error(e);
			//throw e;
		}
    }
    
    //SEND메일 - 하자 작업지시서
    public void mailSend5(String cmpnCd, String mailSubject, String subSubject, StringBuffer mailContent, String sendUser, String recvAddress){

    	String[] activeProfiles = environment.getActiveProfiles();
    	//local 환경에선 메일 전송 불가
		if(activeProfiles[0].equals("local")) {
			//sendEmail5(cmpnCd, recvAddress, sendUser, mailSubject, subSubject, mailContent);
			return;
		}
		//개발환경 메일 세팅
		if(activeProfiles[0].equals("dev")) {
			recvAddress = "테스트메일";
			return;
		}
    	
    	try{
    		// cmpnCd : 회사코드,  mailSubject : 메일제목,  subSubject : 메일소제목, mailContent : 메일내용,  sendUser : 답변자사번, recvAddress : 받는이이메일주소
			sendEmail5(cmpnCd, recvAddress, sendUser, mailSubject, subSubject, mailContent);
			//storage.addObject("mailSendMsg", "");
		}catch(Exception e) {
			//storage.addObject("mailSendMsg", "메일전송에 실패하였습니다.");
        	//storage.setMessage("udap.common.mail.MailSend 매일전송실패.\\n" + e.getMessage());
        }
		
    }
    
    // cmpnCd : 회사코드,  mailSubject : 메일제목,  subSubject : 메일소제목, mailContent : 메일내용,  sendUser : 답변자사번, recvAddress : 받는이이메일주소
    public void sendEmail5(String cmpnCd, String toEmail, String sendUser, String mailSubject, String subSubject, StringBuffer mailContent) {
    	
    	Date today=new Date();
        SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd");       
        String date = formater.format(today);			//오늘날짜										
        
        Mail mail = new Mail();												
        mail.setCmpnCd(cmpnCd);							//회사코드
        mail.setEmpNo(sendUser);						//답변자사번번호
        
        List<EasyHashMap<String, Object>> mailInfo = mailMapper.selectMailCommList(mail);		//메일 INFO
        List<EasyHashMap<String, Object>> userInfo = mailMapper.selectMailUserList(mail);		//답변자 INFO

        String smtpIp 	= (String) mailInfo.get(0).get("esbsCd1");		// 메일서버 주소 설정
		String smtpUser = (String) mailInfo.get(0).get("esbsCd2");		// SMTP인증 아이디
		String smtpPw 	= (String) mailInfo.get(0).get("esbsCd3");		// SMTP인증 비밀번호
		String link 	= (String) mailInfo.get(0).get("esbsCd4");		// 링크
		String cmpn 	= (String) mailInfo.get(0).get("esbsCd5");		// 회사구분
        
        String fromEmail = "";
		String fromName = "";
		String fromDuty = "";
		String fromDept = "";
		String fromTel = "";
		
		fromEmail = (String) userInfo.get(0).get("eMail");							//FROM 이메일주소
		fromName = (String) userInfo.get(0).get("empNm");							//FROM 사원명
		fromDuty = (String) userInfo.get(0).get("aDuty");							//FROM 직급
		fromDept = (String) userInfo.get(0).get("departDeptNm");					//FROM 부서
		fromTel = "고객센터 (1833-2588)";												//FROM 전화번호
			
		Properties properties = new Properties();									// Properties 객체 설정
		properties.put("mail.transport.protocol", "smtp");							// SMTP 프로토콜 사용
		properties.put("mail.smtp.host", smtpIp);									// 메일서버 주소 설정
		properties.put("mail.smtp.port", "25");										// 메일서버 포트 설정
		properties.put("mail.smtp.auth", true);										// 인증 사용 여부
		
		SmtpAuth auth = new SmtpAuth(smtpUser, smtpPw);								// SMTP 인증을 위해서 반드시 필요하다
		
		StringBuffer contentBase = new StringBuffer();								// 메일양식 
		contentBase.append(" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> \n");
		contentBase.append(" <html xmlns='http://www.w3.org/1999/xhtml'> \n");
		contentBase.append(" <head> \n");
		contentBase.append(" <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> \n");
		contentBase.append(" <title>SGC이앤씨</title> \n");
		contentBase.append(" </head> \n");
		contentBase.append(" <body> \n");
		contentBase.append(" <div style='padding:10px; border:#CCC solid 1px;'>                                                                                                                                                                                                            \n");
		contentBase.append(" <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                               \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td height='72'>                                                                                                                                                                                                                                          \n");
		contentBase.append("     <table  border='0' cellpadding='0' cellspacing='0' background='"+link+"/resources/images/mail/top_bg.gif' style='width:100%; background-repeat:repeat-x;'>                                                                                                \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td height='72' align='left' valign='top'><img src='"+link+"/resources/images/mail/top_logo_"+cmpn+".gif' width='187' height='72' alt='SGC이앤씨' /></td>                                                                                            \n");
		contentBase.append("         <td width='100%'>&nbsp;</td>                                                                                                                                                                                                                          \n");
		contentBase.append("         <td align='right' valign='top'></td>                                                                                                                                                           \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("     </table></td>                                                                                                                                                                                                                                             \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td style='padding:20px;'>                                                                                                                                                                                                                                \n");
		contentBase.append("      <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                          \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td width='19' height='46'><img src='"+link+"/resources/images/mail/content_l_01.gif' width='19' height='46' alt='' /></td>                                                                                                                           \n");
//		contentBase.append("         <td width='100%' style=' background-image:url("+link+"/resources/images/mail/content_c.gif); background-repeat:repeat-x; font-family:돋움; font-size:12px; color:#ffffff; text-align:left;'>                                                           \n");
		contentBase.append("         <td width='100%' background='"+link+"/resources/images/mail/content_c.gif' style='background-repeat:repeat-x; font-family:맑은 고딕; font-size:12px; color:#ffffff; text-align:left;'>                                                                     \n");
		contentBase.append("          <table border='0' cellpadding='0' cellspacing='0' style='width:100%'>                                                                                                                                                                                      \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("            <td style='color:#ffffff;'>안녕하세요. <strong>"+fromDept+"  "+fromName+"</strong> 입니다.</td>                                                                                                                                                         \n");
		contentBase.append("            <td align='right' style='color:#ffffff;'>"+date+"</td>                                                                                                                                                                                             \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("          </table>                                                                                                                                                                                                                                             \n");
		contentBase.append("         </td>                                                                                                                                                                                                                                                 \n");
		contentBase.append("         <td width='19'><img src='"+link+"/resources/images/mail/content_r_01.gif' width='19' height='46' alt='' /></td>                                                                                                                                       \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td height='38'><img src='"+link+"/resources/images/mail/content_l_02.gif' width='19' height='38' alt='' /></td>                                                                                                                                      \n");
		contentBase.append("         <td style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; color:#5274ea; text-align:left; line-height:20px;'><strong>"+subSubject+"</strong> 관련하여 메일 보내드리오니 확인  바랍니다. </td>                        \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_02.gif' width='19' height='38' alt='' /></td>                                                                                                                                                  \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style=' background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                \n");
		contentBase.append("         <td  style=' background-repeat:repeat-y; padding-top:20px; padding-bottom:20px; line-height:20px;'><strong style='font-size:12px; color:#5274ea; font-family:맑은 고딕;'>"+mailContent+"</strong></td>                                  \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                       \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style='background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                  \n");
		contentBase.append("         <td align='center' valign='middle' style='padding-top:15px; padding-bottom:15px; border-top:#CCC solid 1px;'><a href='https://as.sgcenc.co.kr/'><img src='"+link+"/resources/images/mail/btn_site.gif' alt='사이트접속하기' width='145' height='28' border='0' /></a></td> \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                       \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_l_04.gif' width='19' height='128' alt='' /></td>                                                                                                                                                 \n");
		contentBase.append("         <td align='left' valign='top' background='"+link+"/resources/images/mail/sign_c.gif' style='background-repeat:repeat-x; text-align:left'>                                                                                                             \n");
		contentBase.append("          <table width='800' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                       \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td colspan='2'><img src='"+link+"/resources/images/mail/sign_logo_"+cmpn+".gif' width='300' height='50' alt='We build your dream SGC이앤씨' /></td>                                                                                             \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                             \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22' align='center' valign='middle'><img src='"+link+"/resources/images/mail/sign_icon.gif' width='13' height='13' alt='' /></td>                                                                                           \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>"+fromDept+"&nbsp;&nbsp;&nbsp;"+fromName+"</td>                                                                        \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                                                                                                            \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>전화 : "+fromTel+"&nbsp;&nbsp;&nbsp;</td>                                                                                           \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                                                                                                            \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>E-Mail : "+fromEmail+"</td>                                                                                                    \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("                                                                                                                                                                                                                                                               \n");
		contentBase.append("         </table></td>                                                                                                                                                                                                                                         \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_04.gif' width='19' height='128' alt='' /></td>                                                                                                                                                 \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("     </table></td>                                                                                                                                                                                                                                             \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td align='left' valign='bottom' bgcolor='#CCCCCC'><img src='"+link+"/resources/images/mail/copy.gif' width='291' height='28' alt='' /></td>                                                                                                              \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append(" </table>                                                                                                                                                                                                                                                      \n");
		contentBase.append(" </div>                                                                                                                                                                                                                                                        \n");
		contentBase.append(" </body> \n");
		contentBase.append(" </html>                                                                                                                                                                                                                                                        \n");
    
		try {
			
			Session session = Session.getInstance(properties, auth);				// Properties 객체와 (인증)auth객체로 메일전송 세션 생성
			MimeMessage msg = new MimeMessage(session);								// 메일 객체를 세션을 통해 생성
			
			InternetAddress[] to_address = {new InternetAddress(toEmail)};			// 받는 사람 메일 주소 객체 생성
			msg.setFrom(new InternetAddress(fromEmail));							// 보내는 사람 메일주소 설정
			msg.setRecipients(Message.RecipientType.TO, to_address);				// 받는 사람 메일 주소를 메일 객체에 매핑
			msg.setContent(contentBase.toString(), "text/html; charset=utf-8");		// 메일 내용을 설정하며 메일 형식을 HTML로 지정
			msg.setSubject(mailSubject,"utf-8");									// 메일 제목 설정
			msg.setSentDate(new Date());											// 보내는 날짜 설정
			System.out.print(msg.getContent());
			Transport.send(msg);													// 메일 전송 부분
			
		} catch(MessagingException me) {
			//WAFLogger.error(this.getClass().getName() + " --> sendEmail() : \n" + me.getMessage());
			//WAFLogger.error(me);
			//throw me;
		} catch(Exception e) {
			//WAFLogger.error(this.getClass().getName() + " --> sendEmail() : \n" + e.getMessage());
			//WAFLogger.error(e);
			//throw e;
		}
    }
    
    //MH (직원용)
    public void mailSend6(String mailSubject, String subSubject, String dateSubject, String cmpnCd, String empNo, String empNm, String deptNm, String recvAddress, String dtmStr, String dtmHStr){
    	
    	String[] activeProfiles = environment.getActiveProfiles();
    	
    	//local 환경에선 메일 전송 불가
		if(activeProfiles[0].equals("local")) {
			logger.info("[MYTEST] test batch {}", recvAddress);
			return;
		}
		//개발환경 메일 세팅
		if(activeProfiles[0].equals("dev")) {
			//recvAddress = "park.sh@sgc.co.kr";
			recvAddress = "테스트메일";
			return;
		}
    	
    	try{
    		sendEmail6(cmpnCd, recvAddress, mailSubject, subSubject, dateSubject, empNo, empNm, deptNm, dtmStr, dtmHStr);	
		}catch(Exception e) {
			
        }
		
    }
    
    /**
	 * 이메일 전송 메소드(Javamail 사용)
	 * @param user
	 * @param from_email
	 * @param to_name
	 * @param to_email
	 */
    public void sendEmail6(String cmpnCd, String toEmail, String mailSubject, String subSubject, String dateSubject, String empNo, String empNm, String deptNm, String dtmStr, String dtmHStr) throws Exception{
		
    	Date today=new Date();
        SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd");       
        String date = formater.format(today);
        
        Mail mail = new Mail();												
        mail.setCmpnCd(cmpnCd);
        
        List<EasyHashMap<String, Object>> mailInfo = mailMapper.selectMailCommList(mail);		//메일 INFO

        String smtpIp 	= (String) mailInfo.get(0).get("esbsCd1");		// 메일서버 주소 설정
		String smtpUser = (String) mailInfo.get(0).get("esbsCd2");		// SMTP인증 아이디
		String smtpPw 	= (String) mailInfo.get(0).get("esbsCd3");		// SMTP인증 비밀번호
		String link 	= (String) mailInfo.get(0).get("esbsCd4");		// 링크
		String cmpn 	= (String) mailInfo.get(0).get("esbsCd5");		// 회사구분
		
		String fromEmail = "hradmin@sgc.co.kr";
		String fromName = "SGC포탈 시스템 관리자";
		String fromDuty = "";
		String fromDept = "본사";
		String fromTel = "02-489-9000";
		
		Properties properties = new Properties();									// Properties 객체 설정
		properties.put("mail.transport.protocol", "smtp");							// SMTP 프로토콜 사용
		properties.put("mail.smtp.host", smtpIp);									// 메일서버 주소 설정
		properties.put("mail.smtp.port", "25");										// 메일서버 포트 설정
		properties.put("mail.smtp.auth", true);										// 인증 사용 여부
		
		SmtpAuth auth = new SmtpAuth(smtpUser, smtpPw);								// SMTP 인증을 위해서 반드시 필요하다

		StringBuffer contentBase = new StringBuffer();
		contentBase.append(" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> \n");
		contentBase.append(" <html xmlns='http://www.w3.org/1999/xhtml'> \n");
		contentBase.append(" <head> \n");
		contentBase.append(" <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> \n");
		contentBase.append(" <title>SGC이앤씨</title> \n");
		contentBase.append(" </head> \n");
		contentBase.append(" <body> \n");
		contentBase.append(" <div style='padding:10px; border:#CCC solid 1px;'>                                                                                                                   \n");
		contentBase.append(" <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                      \n");
		contentBase.append("   <tr>                                                                                                                                                               \n");
		contentBase.append("     <td height='72'>                                                                                                                                                 \n");
		contentBase.append("     <table  border='0' cellpadding='0' cellspacing='0' background='"+link+"/resources/images/mail/top_bg.gif' style='width:100%; background-repeat:repeat-x;'>       \n");
		contentBase.append("       <tr>                                                                                                                                                           \n");
		contentBase.append("         <td height='72' align='left' valign='top'><img src='"+link+"/resources/images/mail/top_logo_"+cmpn+".gif' width='187' height='72' alt='SGC이앤씨' /></td>   \n");
		contentBase.append("         <td width='100%'>&nbsp;</td>                                                                                                                                 \n");
		contentBase.append("         <td align='right' valign='top'></td>                                                                                                                         \n");
		contentBase.append("       </tr>                                                                                                                                                          \n");
		contentBase.append("     </table></td>                                                                                                                                                    \n");
		contentBase.append("   </tr>                                                                                                                                                              \n");
		contentBase.append("   <tr>                                                                                                                                                               \n");
		contentBase.append("     <td style='padding:20px;'>                                                                                                                                       \n");
		contentBase.append("      <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                 \n");
		contentBase.append("       <tr>                                                                                                                                                           \n");
		contentBase.append("         <td width='19' height='46'><img src='"+link+"/resources/images/mail/content_l_01.gif' width='19' height='46' alt='' /></td>                                  \n");
		contentBase.append("         <td width='100%' background='"+link+"/resources/images/mail/content_c.gif' style='background-repeat:repeat-x; font-family:맑은 고딕; font-size:12px; color:#ffffff; text-align:left;'>   \n");
		contentBase.append("          <table border='0' cellpadding='0' cellspacing='0' style='width:100%'>                                                                                                                    \n");
		contentBase.append("           <tr>                                                                                                                                                                              \n");
		contentBase.append("            <td style='color:#ffffff;'></td>                                                                                                                                                 \n");
		contentBase.append("            <td align='right' style='color:#ffffff;'>"+date+" "+dateSubject+"</td>                                                                                                                           \n");
		contentBase.append("           </tr>                                                                                                                                                                             \n");
		contentBase.append("          </table>                                                                                                                                                                           \n");
		contentBase.append("         </td>                                                                                                                                                                               \n");
		contentBase.append("         <td width='19'><img src='"+link+"/resources/images/mail/content_r_01.gif' width='19' height='46' alt='' /></td>                                                                     \n");
		contentBase.append("       </tr>                                                                                                                                                                                 \n");
		contentBase.append("       <tr>                                                                                                                                                                                  \n");
		contentBase.append("         <td height='38'><img src='"+link+"/resources/images/mail/content_l_02.gif' width='19' height='38' alt='' /></td>                                                                    \n");
		contentBase.append("         <td style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; color:#5274ea; text-align:left; line-height:20px;'><strong>"+subSubject+"</strong> 안내 드립니다. </td> \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_02.gif' width='19' height='38' alt='' /></td>                                                                                \n");
		contentBase.append("       </tr>                                                                                                                                                                                 \n");
		contentBase.append("       <tr>                                                                                                                                                                                  \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style=' background-repeat:repeat-y;'>&nbsp;</td>                                                              \n");
		contentBase.append("         <td  style=' background-repeat:repeat-y; padding-top:20px; padding-bottom:20px; line-height:20px;'><strong style='font-size:12px; color:#5274ea; font-family:맑은 고딕;'>"+dtmHStr+"</strong></td>  \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                  \n");
		contentBase.append("       </tr>                                                                                                                                                                                              \n");
		contentBase.append("       <tr>                                                                                                                                                                                               \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style=' background-repeat:repeat-y;'>&nbsp;</td>                                                                           \n");
		contentBase.append("         <td  style=' background-repeat:repeat-y; padding-top:20px; padding-bottom:20px; font-size:12px; color:#5274ea; font-family:맑은 고딕; line-height:20px;'><pre>				                          \n");
		contentBase.append("		  <table width='600' border='1' cellpadding='1' cellspacing='1'>			\n");
		contentBase.append("		   <tr>																	\n");
		contentBase.append("			<td colspan='6' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'><strong>인적사항</strong></td>					  \n");
		contentBase.append("		   </tr>																	\n");
		contentBase.append("		   <tr>																	\n");
		contentBase.append("			<td width='10%' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>소속</td>										  \n");
		contentBase.append("			<td width='30%' align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>"+deptNm+"</td>												              \n");
		contentBase.append("			<td width='10%' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>사번</td>										  \n");
		contentBase.append("			<td width='20%' align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>"+empNo+"</td>												              \n");
		contentBase.append("			<td width='10%' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>성명</td>										  \n");
		contentBase.append("			<td width='20%' align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>"+empNm+"</td>												              \n");
		contentBase.append("		   </tr>																	\n");
		contentBase.append("		   <tr>																	\n");
		contentBase.append("			<td colspan='6' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'><strong>M/H 미등록 일자</strong></td> \n");
		contentBase.append("		   </tr>																	\n");
		contentBase.append("		   <tr>																	\n");
		contentBase.append("			<td colspan='6' align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>"+dtmStr+"</td> \n");
		contentBase.append("		   </tr>																	\n");
		contentBase.append("		  </table>																\n");		
		contentBase.append("		 </pre></td>                                                                \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td> \n");
		contentBase.append("       </tr>                                                                                                                                             \n");
		contentBase.append("       <tr>                                                                                                                                              \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style='background-repeat:repeat-y;'>&nbsp;</td>                            \n");
		contentBase.append("       	 <td></td>                                                                                                                                       \n");				
//		contentBase.append("         <td align='center' valign='middle' style='padding-top:15px; padding-bottom:15px; border-top:#CCC solid 1px;'><a href='https://portal.sgc.co.kr/websquare/'><img src='"+link+"/resources/images/mail/btn_site.gif' alt='사이트접속하기' width='145' height='28' border='0' /></a></td> \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>             \n");
		contentBase.append("       </tr>                                                                                                                                                         \n");
		contentBase.append("       <tr>                                                                                                                                                          \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_l_04.gif' width='19' height='128' alt='' /></td>                                                       \n");
		contentBase.append("         <td align='left' valign='top' background='"+link+"/resources/images/mail/sign_c.gif' style='background-repeat:repeat-x; text-align:left'>                   \n");
		contentBase.append("          <table width='800' border='0' cellpadding='0' cellspacing='0'>                                                                                             \n");
		contentBase.append("           <tr>                                                                                                                                                      \n");
		contentBase.append("             <td colspan='2'><img src='"+link+"/resources/images/mail/sign_logo_"+cmpn+".gif' width='300' height='50' alt='We build your dream SGC이앤씨' /></td>   \n");
		contentBase.append("           </tr>                                                                                                                                                   \n");
		contentBase.append("           <tr>                                                                                                                                                      \n");		
		contentBase.append("             <td width='36' height='22' align='center' valign='middle'><img src='"+link+"/resources/images/mail/sign_icon.gif' width='13' height='13' alt='' /></td> \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>"+fromDept+"&nbsp;&nbsp;&nbsp;"+fromDuty+"&nbsp;&nbsp;"+fromName+"</td> \n");
		contentBase.append("           </tr>                                                                                                                                                              \n");
		contentBase.append("           <tr>                                                                                                                                                               \n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                           \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>전화 : "+fromTel+"&nbsp;&nbsp;&nbsp;</td>                                 \n");
		contentBase.append("           </tr>                                                                                                                                                              \n");
		contentBase.append("           <tr>                                                                                                                                                               \n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                           \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>E-Mail : "+fromEmail+"</td>                                             \n");
		contentBase.append("           </tr>                                                                                                                                                              \n");
		contentBase.append("                                                                                                                                                                              \n");
		contentBase.append("         </table></td>                                                                                                                                                        \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_04.gif' width='19' height='128' alt='' /></td>                                                                \n");
		contentBase.append("       </tr>                                                                                                                                                                  \n");
		contentBase.append("     </table></td>                                                                                                                                                            \n");
		contentBase.append("   </tr>                                                                                                                                                                      \n");
		contentBase.append("   <tr>                                                                                                                                                                       \n");
		contentBase.append("     <td align='left' valign='bottom' bgcolor='#CCCCCC'><img src='"+link+"/resources/images/mail/copy.gif' width='291' height='28' alt='' /></td>                             \n");
		contentBase.append("   </tr>                                                                                                                                                                      \n");
		contentBase.append(" </table>                                                                                                                                                                     \n");
		contentBase.append(" </div>                                                                                                                                                                       \n");
		contentBase.append(" </body> 																																									  \n");                                                                                                                                                                
		contentBase.append(" </html>                                                                                                                                                                      \n");
		
		try {
			
			Session session = Session.getInstance(properties, auth);				// Properties 객체와 auth(인증)객체로 메일전송 세션 생성
			MimeMessage msg = new MimeMessage(session);								// 메일 객체를 세션을 통해 생성
			
			InternetAddress[] to_address = {new InternetAddress(toEmail)};			// 받는 사람 메일 주소 객체 생성
			
			InternetAddress addr = new InternetAddress();  
			addr.setPersonal(fromName,"UTF-8");  
			addr.setAddress(fromEmail);
			
			msg.setFrom(addr);							// 보내는 사람 메일주소 설정
			
			msg.setRecipients(Message.RecipientType.TO, to_address);				// 받는 사람 메일 주소를 메일 객체에 매핑
			msg.setContent(contentBase.toString(), "text/html; charset=utf-8");					// 메일 내용을 설정하며 메일 형식을 HTML로 지정
			msg.setSubject(mailSubject,"utf-8");									// 메일 제목 설정
			msg.setSentDate(new Date());											// 보내는 날짜 설정
			
			Transport.send(msg);													// 메일 전송 부분
			
		} catch(MessagingException me) {
		} catch(Exception e) {
		}
	}
    
    //MH (담당자)
    public void mailSend7(String mailSubject, String subSubject, String dateSubject, String cmpnCd, String recvAddress, String dtmStr, String dtmStr2){
    	
    	String[] activeProfiles = environment.getActiveProfiles();
    	
    	//local 환경에선 메일 전송 불가
		if(activeProfiles[0].equals("local")) {
			logger.info("[MYTEST] test batch {}", recvAddress);
			return;
		}
		//개발환경 메일 세팅
		if(activeProfiles[0].equals("dev")) {
			//recvAddress = "park.sh@sgc.co.kr";
			recvAddress = "테스트메일";
			return;
		}
    	
    	try{
    		sendEmail7(cmpnCd, recvAddress, mailSubject, subSubject, dateSubject, dtmStr, dtmStr2);	
		}catch(Exception e) {
			
        }
		
    }
    
    /**
	 * 이메일 전송 메소드(Javamail 사용)
	 * @param user
	 * @param from_email
	 * @param to_name
	 * @param to_email
	 */
    public void sendEmail7(String cmpnCd, String toEmail, String mailSubject, String subSubject, String dateSubject, String dtmStr, String dtmStr2) throws Exception{
		
    	Date today=new Date();
        SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd");       
        String date = formater.format(today);
        
        Mail mail = new Mail();												
        mail.setCmpnCd(cmpnCd);
        
        List<EasyHashMap<String, Object>> mailInfo = mailMapper.selectMailCommList(mail);		//메일 INFO

        String smtpIp 	= (String) mailInfo.get(0).get("esbsCd1");		// 메일서버 주소 설정
		String smtpUser = (String) mailInfo.get(0).get("esbsCd2");		// SMTP인증 아이디
		String smtpPw 	= (String) mailInfo.get(0).get("esbsCd3");		// SMTP인증 비밀번호
		String link 	= (String) mailInfo.get(0).get("esbsCd4");		// 링크
		String cmpn 	= (String) mailInfo.get(0).get("esbsCd5");		// 회사구분
		
		String fromEmail = "hradmin@sgc.co.kr";
		String fromName = "SGC포탈 시스템 관리자";
		String fromDuty = "";
		String fromDept = "본사";
		String fromTel = "02-489-9000";
		
		Properties properties = new Properties();									// Properties 객체 설정
		properties.put("mail.transport.protocol", "smtp");							// SMTP 프로토콜 사용
		properties.put("mail.smtp.host", smtpIp);									// 메일서버 주소 설정
		properties.put("mail.smtp.port", "25");										// 메일서버 포트 설정
		properties.put("mail.smtp.auth", true);										// 인증 사용 여부
		
		SmtpAuth auth = new SmtpAuth(smtpUser, smtpPw);								// SMTP 인증을 위해서 반드시 필요하다

		StringBuffer contentBase = new StringBuffer();
		contentBase.append(" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> 																		\n");
		contentBase.append(" <html xmlns='http://www.w3.org/1999/xhtml'> 																																					\n");
		contentBase.append(" <head> 																																														\n");
		contentBase.append(" <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> 																															\n");
		contentBase.append(" <title>SGC이앤씨</title> 																																											\n");
		contentBase.append(" </head> 																																														\n");
		contentBase.append(" <body> 																																														\n");
		contentBase.append(" <div style='padding:10px; border:#CCC solid 1px;'>                                                                                                                   							\n");
		contentBase.append(" <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                      							\n");
		contentBase.append("   <tr>                                                                                                                                                               							\n");
		contentBase.append("     <td height='72'>                                                                                                                                                 							\n");
		contentBase.append("     <table  border='0' cellpadding='0' cellspacing='0' background='"+link+"/resources/images/mail/top_bg.gif' style='width:100%; background-repeat:repeat-x;'>       							\n");
		contentBase.append("       <tr>                                                                                                                                                           							\n");
		contentBase.append("         <td height='72' align='left' valign='top'><img src='"+link+"/resources/images/mail/top_logo_"+cmpn+".gif' width='187' height='72' alt='SGC이앤씨' /></td>   							\n");
		contentBase.append("         <td width='100%'>&nbsp;</td>                                                                                                                                 							\n");
		contentBase.append("         <td align='right' valign='top'></td>                                                                                                                         							\n");
		contentBase.append("       </tr>                                                                                                                                                          							\n");
		contentBase.append("     </table></td>                                                                                                                                                    							\n");
		contentBase.append("   </tr>                                                                                                                                                              							\n");
		contentBase.append("   <tr>                                                                                                                                                               							\n");
		contentBase.append("     <td style='padding:20px;'>                                                                                                                                       							\n");
		contentBase.append("      <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                 							\n");
		contentBase.append("       <tr>                                                                                                                                                           							\n");
		contentBase.append("         <td width='19' height='46'><img src='"+link+"/resources/images/mail/content_l_01.gif' width='19' height='46' alt='' /></td>                                  							\n");
		contentBase.append("         <td width='100%' background='"+link+"/resources/images/mail/content_c.gif' style='background-repeat:repeat-x; font-family:맑은 고딕; font-size:12px; color:#ffffff; text-align:left;'>		\n");
		contentBase.append("          <table border='0' cellpadding='0' cellspacing='0' style='width:100%'>                                                                                                                   	\n");
		contentBase.append("           <tr>                                                                                                                                                                             	\n");
		contentBase.append("            <td style='color:#ffffff;'></td>                                                                                                                                                	\n");
		contentBase.append("            <td align='right' style='color:#ffffff;'>"+date+" "+dateSubject+"</td>                                                                                                          	\n");
		contentBase.append("           </tr>                                                                                                                                                                            	\n");
		contentBase.append("          </table>                                                                                                                                                                          	\n");
		contentBase.append("         </td>                                                                                                                                                                              	\n");
		contentBase.append("         <td width='19'><img src='"+link+"/resources/images/mail/content_r_01.gif' width='19' height='46' alt='' /></td>                                                                    	\n");
		contentBase.append("       </tr>                                                                                                                                                                                	\n");
		contentBase.append("       <tr>                                                                                                                                                                                 	\n");
		contentBase.append("         <td height='38'><img src='"+link+"/resources/images/mail/content_l_02.gif' width='19' height='38' alt='' /></td>                                                                   	\n");
		contentBase.append("         <td style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; color:#5274ea; text-align:left; line-height:20px;'><strong>"+subSubject+"</strong> 안내 드립니다. </td> 			\n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_02.gif' width='19' height='38' alt='' /></td>                                                                               	\n");
		contentBase.append("       </tr>                                                                                                                                                                                	\n");
		contentBase.append("       <tr>                                                                                                                                                                                 	\n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style=' background-repeat:repeat-y;'>&nbsp;</td>                                                              	\n");
		contentBase.append("         <td  style=' background-repeat:repeat-y; padding-top:20px; padding-bottom:20px; font-size:12px; color:#5274ea; font-family:맑은 고딕; line-height:20px;'><pre>				            	\n");
		contentBase.append("		  <table width='600' border='1' cellpadding='1' cellspacing='1'>																														\n");
		contentBase.append("		   <tr>																																													\n");
		contentBase.append("			<td colspan='6' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'><strong>M/H 미입력자</strong></td> 			\n");
		contentBase.append("		   </tr>																																												\n");
		contentBase.append("		   <tr>																																													\n");
		contentBase.append("			<td colspan='6' align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:left; line-height:20px;'>"+dtmStr+"</td> 														\n");
		contentBase.append("		   </tr>																																												\n");
		contentBase.append("		   <tr>																																													\n");
		contentBase.append("			<td colspan='6' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'><strong>M/H 승인요청하지 않은자</strong></td>	\n");
		contentBase.append("		   </tr>																																												\n");
		contentBase.append("		   <tr>																																													\n");
		contentBase.append("			<td colspan='6' align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:left; line-height:20px;'>"+dtmStr2+"</td> 														\n");
		contentBase.append("		   </tr>																																												\n");
		contentBase.append("		  </table>																																												\n");		
		contentBase.append("		 </pre></td>                                                                																											\n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td> 										\n");
		contentBase.append("       </tr>                                                                                                                                             										\n");
		contentBase.append("       <tr>                                                                                                                                              										\n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style='background-repeat:repeat-y;'>&nbsp;</td>                            										\n");
		contentBase.append("       	 <td></td>                                                                                                                                       										\n");				
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>             							\n");
		contentBase.append("       </tr>                                                                                                                                                         							\n");
		contentBase.append("       <tr>                                                                                                                                                          							\n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_l_04.gif' width='19' height='128' alt='' /></td>                                                       							\n");
		contentBase.append("         <td align='left' valign='top' background='"+link+"/resources/images/mail/sign_c.gif' style='background-repeat:repeat-x; text-align:left'>                   							\n");
		contentBase.append("          <table width='800' border='0' cellpadding='0' cellspacing='0'>                                                                                             							\n");
		contentBase.append("           <tr>                                                                                                                                                      							\n");
		contentBase.append("             <td colspan='2'><img src='"+link+"/resources/images/mail/sign_logo_"+cmpn+".gif' width='300' height='50' alt='We build your dream SGC이앤씨' /></td>   							\n");
		contentBase.append("           </tr>                                                                                                                                                   								\n");
		contentBase.append("           <tr>                                                                                                                                                      							\n");		
		contentBase.append("             <td width='36' height='22' align='center' valign='middle'><img src='"+link+"/resources/images/mail/sign_icon.gif' width='13' height='13' alt='' /></td> 							\n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>"+fromDept+"&nbsp;&nbsp;&nbsp;"+fromDuty+"&nbsp;&nbsp;"+fromName+"</td> 					\n");
		contentBase.append("           </tr>                                                                                                                                                              					\n");
		contentBase.append("           <tr>                                                                                                                                                               					\n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                           					\n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>전화 : "+fromTel+"&nbsp;&nbsp;&nbsp;</td>                                 					\n");
		contentBase.append("           </tr>                                                                                                                                                              					\n");
		contentBase.append("           <tr>                                                                                                                                                               					\n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                           					\n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>E-Mail : "+fromEmail+"</td>                                             					\n");
		contentBase.append("           </tr>                                                                                                                                                              					\n");
		contentBase.append("                                                                                                                                                                              					\n");
		contentBase.append("         </table></td>                                                                                                                                                        					\n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_04.gif' width='19' height='128' alt='' /></td>                                                                					\n");
		contentBase.append("       </tr>                                                                                                                                                                  					\n");
		contentBase.append("     </table></td>                                                                                                                                                            					\n");
		contentBase.append("   </tr>                                                                                                                                                                      					\n");
		contentBase.append("   <tr>                                                                                                                                                                       					\n");
		contentBase.append("     <td align='left' valign='bottom' bgcolor='#CCCCCC'><img src='"+link+"/resources/images/mail/copy.gif' width='291' height='28' alt='' /></td>                             					\n");
		contentBase.append("   </tr>                                                                                                                                                                      					\n");
		contentBase.append(" </table>                                                                                                                                                                     					\n");
		contentBase.append(" </div>                                                                                                                                                                       					\n");
		contentBase.append(" </body> 																																									  					\n");
		contentBase.append(" </html>                                                                                                                                                                      					\n");
		
		try {
			
			Session session = Session.getInstance(properties, auth);				// Properties 객체와 auth(인증)객체로 메일전송 세션 생성
			MimeMessage msg = new MimeMessage(session);								// 메일 객체를 세션을 통해 생성
			
			InternetAddress[] to_address = {new InternetAddress(toEmail)};			// 받는 사람 메일 주소 객체 생성
			
			InternetAddress addr = new InternetAddress();  
			addr.setPersonal(fromName,"UTF-8");  
			addr.setAddress(fromEmail);
			
			msg.setFrom(addr);							// 보내는 사람 메일주소 설정
			
			msg.setRecipients(Message.RecipientType.TO, to_address);				// 받는 사람 메일 주소를 메일 객체에 매핑
			msg.setContent(contentBase.toString(), "text/html; charset=utf-8");					// 메일 내용을 설정하며 메일 형식을 HTML로 지정
			msg.setSubject(mailSubject,"utf-8");									// 메일 제목 설정
			msg.setSentDate(new Date());											// 보내는 날짜 설정
			
			Transport.send(msg);													// 메일 전송 부분
			
		} catch(MessagingException me) {
		} catch(Exception e) {
		}
	}
    
    //항공권 발권
    public void mailSend8(String cmpnCd, String mailSubject, String recvAddress, String str1, String str2, String str3, String str4, String str5, String fromEmail, String fromName){

		//mailService.mailSend8(cmpnCd, sSubject, sContent, sSender, srecvAddress);
    	String[] activeProfiles = environment.getActiveProfiles();
    	
    	//local 환경에선 메일 전송 불가
		if(activeProfiles[0].equals("local")) {
			recvAddress = "park.sh@sgc.co.kr";
			logger.info("[MYTEST] test batch {}", recvAddress);
			//return;
		}
		//개발환경 메일 세팅
		if(activeProfiles[0].equals("dev")) {
			//recvAddress = "park.sh@sgc.co.kr";
			recvAddress = "테스트메일";
			return;
		}
    	
    	try{
    		sendEmail8(cmpnCd, recvAddress, mailSubject, str1, str2, str3, str4, str5, fromEmail, fromName);	
		}catch(Exception e) {
			
        }
		
    }
    
    /**
	 * 이메일 전송 메소드(Javamail 사용)
	 * @param user
	 * @param from_email
	 * @param to_name
	 * @param to_email
	 */
    public void sendEmail8(String cmpnCd, String toEmail, String mailSubject, String str1, String str2, String str3, String str4, String str5, String fromEmail, String fromName) throws Exception{
		
    	Date today=new Date();
        SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd");       
        String date = formater.format(today);
        
        Mail mail = new Mail();												
        mail.setCmpnCd(cmpnCd);
        
        List<EasyHashMap<String, Object>> mailInfo = mailMapper.selectMailCommList(mail);		//메일 INFO

        String smtpIp 	= (String) mailInfo.get(0).get("esbsCd1");		// 메일서버 주소 설정
		String smtpUser = (String) mailInfo.get(0).get("esbsCd2");		// SMTP인증 아이디
		String smtpPw 	= (String) mailInfo.get(0).get("esbsCd3");		// SMTP인증 비밀번호
		String link 	= (String) mailInfo.get(0).get("esbsCd4");		// 링크
		String cmpn 	= (String) mailInfo.get(0).get("esbsCd5");		// 회사구분
		
		//String fromEmail = "hradmin@sgc.co.kr";
		//String fromName = "SGC포탈 시스템 관리자";
		
		Properties properties = new Properties();									// Properties 객체 설정
		properties.put("mail.transport.protocol", "smtp");							// SMTP 프로토콜 사용
		properties.put("mail.smtp.host", smtpIp);									// 메일서버 주소 설정
		properties.put("mail.smtp.port", "25");										// 메일서버 포트 설정
		properties.put("mail.smtp.auth", true);										// 인증 사용 여부
		
		SmtpAuth auth = new SmtpAuth(smtpUser, smtpPw);								// SMTP 인증을 위해서 반드시 필요하다

		StringBuffer contentBase = new StringBuffer();
		contentBase.append(" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> 																		\n");
		contentBase.append(" <html xmlns='http://www.w3.org/1999/xhtml'> 																																					\n");
		contentBase.append(" <head> 																																														\n");
		contentBase.append(" <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> 																															\n");
		contentBase.append(" <title>SGC이앤씨</title> 																																											\n");
		contentBase.append(" </head> 																																														\n");
		contentBase.append(" <body> 																																														\n");
		contentBase.append(" <div style='padding:10px; border:#CCC solid 1px;'>                                                                                                                   							\n");
		contentBase.append(" <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                      							\n");
		contentBase.append("   <tr>                                                                                                                                                               							\n");
		contentBase.append("     <td height='72'>                                                                                                                                                 							\n");
		contentBase.append("     <table  border='0' cellpadding='0' cellspacing='0' background='"+link+"/resources/images/mail/top_bg.gif' style='width:100%; background-repeat:repeat-x;'>       							\n");
		contentBase.append("       <tr>                                                                                                                                                           							\n");
		contentBase.append("         <td height='72' align='left' valign='top'><img src='"+link+"/resources/images/mail/top_logo_"+cmpn+".gif' width='187' height='72' alt='SGC이앤씨' /></td>   							\n");
		contentBase.append("       </tr>                                                                                                                                                          							\n");
		contentBase.append("       <tr>                                                                                                                                                           							\n");
		contentBase.append("       <td width='720'></td>                                                                                                                                                           			\n");
		contentBase.append("       </tr>                                                                                                                                                           							\n");
		contentBase.append("	   <tr>																																													\n");
		contentBase.append("		 <td style='padding:20px;'></td> 														\n");
		contentBase.append("	   </tr>																																												\n");
		contentBase.append("	   <tr>																																													\n");
		contentBase.append("		 <td>"+str1+"</td> 														\n");
		contentBase.append("	   </tr>																																												\n");
		contentBase.append("	   <tr>																																													\n");
		contentBase.append("		 <td style='padding:10px;'></td> 														\n");
		contentBase.append("	   </tr>																																												\n");
		contentBase.append("	   <tr>																																													\n");
		contentBase.append("		 <td>"+str2+"</td> 														\n");
		contentBase.append("	   </tr>																																												\n");
		contentBase.append("	   <tr>																																													\n");
		contentBase.append("		 <td style='padding:10px;'></td> 														\n");
		contentBase.append("	   </tr>																																												\n");
		contentBase.append("	   <tr>																																													\n");
		contentBase.append("		 <td>"+str3+"</td> 														\n");
		contentBase.append("	   </tr>																																												\n");
		contentBase.append("	   <tr>																																													\n");
		contentBase.append("		 <td style='padding:10px;'></td> 														\n");
		contentBase.append("	   </tr>																																												\n");
		contentBase.append("	   <tr>																																													\n");
		contentBase.append("		 <td>"+str4+"</td> 														\n");
		contentBase.append("	   </tr>																																												\n");
		contentBase.append("	   <tr>																																													\n");
		contentBase.append("		 <td>"+str5+"</td> 														\n");
		contentBase.append("	   </tr>																																												\n");
		contentBase.append("     </table></td>                                                                                                                                                    							\n");
		contentBase.append("   </tr>                                                                                                                                                              							\n");
		contentBase.append("   <tr>                                                                                                                                                               							\n");
		contentBase.append("     <td style='padding:20px;'>                                                                                                                                       							\n");
		contentBase.append("     </td>                                                                                                                                                            					\n");
		contentBase.append("   </tr>                                                                                                                                                                      					\n");
		contentBase.append("   <tr>                                                                                                                                                                       					\n");
		contentBase.append("     <td align='left' valign='bottom' bgcolor='#CCCCCC'><img src='"+link+"/resources/images/mail/copy.gif' width='291' height='28' alt='' /></td>                             					\n");
		contentBase.append("   </tr>                                                                                                                                                                      					\n");
		contentBase.append(" </table>                                                                                                                                                                     					\n");
		contentBase.append(" </div>                                                                                                                                                                       					\n");
		contentBase.append(" </body> 																																									  					\n");
		contentBase.append(" </html>                                                                                                                                                                      					\n");
		
		try {
			
			Session session = Session.getInstance(properties, auth);				// Properties 객체와 auth(인증)객체로 메일전송 세션 생성
			MimeMessage msg = new MimeMessage(session);								// 메일 객체를 세션을 통해 생성
			
			InternetAddress[] to_address = {new InternetAddress(toEmail)};			// 받는 사람 메일 주소 객체 생성
			
			InternetAddress addr = new InternetAddress();  
			addr.setPersonal(fromName,"UTF-8");  
			addr.setAddress(fromEmail);
			
			msg.setFrom(addr);							// 보내는 사람 메일주소 설정
			
			msg.setRecipients(Message.RecipientType.TO, to_address);				// 받는 사람 메일 주소를 메일 객체에 매핑
			msg.setContent(contentBase.toString(), "text/html; charset=utf-8");					// 메일 내용을 설정하며 메일 형식을 HTML로 지정
			msg.setSubject(mailSubject,"utf-8");									// 메일 제목 설정
			msg.setSentDate(new Date());											// 보내는 날짜 설정
			
			Transport.send(msg);													// 메일 전송 부분
			
		} catch(MessagingException me) {
		} catch(Exception e) {
		}
	}
    
    
    public void mailSend9(String mailSubject, String subSubject, String cmpnCd, String empNo, String empNm, String recvAddress, String contents, String contents2){
    	
    	String[] activeProfiles = environment.getActiveProfiles();
    	
    	//local 환경에선 메일 전송 불가
		if(activeProfiles[0].equals("local")) {
			logger.info("[MYTEST] test batch {}", recvAddress);
			return;
		}
		//개발환경 메일 세팅
		if(activeProfiles[0].equals("dev")) {
			recvAddress = "테스트메일";
			return;
		}
    	
    	try{
    		sendEmail9(cmpnCd, recvAddress, mailSubject, subSubject, empNo, empNm, contents, contents2);	
		}catch(Exception e) {
			
        }
		
    }
    
    /**
	 * 이메일 전송 메소드(Javamail 사용)
	 * @param user
	 * @param from_email
	 * @param to_name
	 * @param to_email
	 */
    public void sendEmail9(String cmpnCd, String toEmail, String mailSubject, String subSubject, String empNo, String empNm, String contents, String contents2) throws Exception{
		
    	Date today=new Date();
        SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd");       
        String date = formater.format(today);
        
        Mail mail = new Mail();												
        mail.setCmpnCd(cmpnCd);
        
        List<EasyHashMap<String, Object>> mailInfo = mailMapper.selectMailCommList(mail);		//메일 INFO

        String smtpIp 	= (String) mailInfo.get(0).get("esbsCd1");		// 메일서버 주소 설정
		String smtpUser = (String) mailInfo.get(0).get("esbsCd2");		// SMTP인증 아이디
		String smtpPw 	= (String) mailInfo.get(0).get("esbsCd3");		// SMTP인증 비밀번호
		String link 	= (String) mailInfo.get(0).get("esbsCd4");		// 링크
		String cmpn 	= (String) mailInfo.get(0).get("esbsCd5");		// 회사구분
		
		String fromEmail = "hradmin@sgc.co.kr";
		String fromName = "SGC포탈 시스템 관리자";
		String fromDuty = "";
		String fromDept = "본사";
		String fromTel = "02-489-9000";
		
		Properties properties = new Properties();									// Properties 객체 설정
		properties.put("mail.transport.protocol", "smtp");							// SMTP 프로토콜 사용
		properties.put("mail.smtp.host", smtpIp);									// 메일서버 주소 설정
		properties.put("mail.smtp.port", "25");										// 메일서버 포트 설정
		properties.put("mail.smtp.auth", true);										// 인증 사용 여부
		
		SmtpAuth auth = new SmtpAuth(smtpUser, smtpPw);								// SMTP 인증을 위해서 반드시 필요하다

		StringBuffer contentBase = new StringBuffer();
		contentBase.append(" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>                                                                                                                                                                                                      \n");
		contentBase.append(" <html xmlns='http://www.w3.org/1999/xhtml'>                                                                                                                                                                                                     \n");
		contentBase.append(" <head> \n");
		contentBase.append(" <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> \n");
		contentBase.append(" <title>SGC이앤씨</title> \n");
		contentBase.append(" </head> \n");
		contentBase.append(" <body> \n");
		contentBase.append(" <div style='padding:10px; border:#CCC solid 1px;'>                                                                                                                                                                                                            \n");
		contentBase.append(" <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                               \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td height='72'>                                                                                                                                                                                                                                          \n");
		contentBase.append("     <table  border='0' cellpadding='0' cellspacing='0' background='"+link+"/resources/images/mail/top_bg.gif' style='width:100%; background-repeat:repeat-x;'>                                                                                                                 \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td height='72' align='left' valign='top'><img src='"+link+"/resources/images/mail/top_logo_"+cmpn+".gif' width='187' height='72' alt='SGC이앤씨' /></td>                                                                                                                            \n");
		contentBase.append("         <td width='100%'>&nbsp;</td>                                                                                                                                                                                                                          \n");
		contentBase.append("         <td align='right' valign='top'></td>                                                                                                                                                           \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("     </table></td>                                                                                                                                                                                                                                             \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td style='padding:20px;'>                                                                                                                                                                                                                                \n");
		contentBase.append("      <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                          \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td width='19' height='46'><img src='"+link+"/resources/images/mail/content_l_01.gif' width='19' height='46' alt='' /></td>                                                                                                                                                             \n");
//		contentBase.append("         <td width='100%' style=' background-image:url("+link+"/resources/images/mail/content_c.gif); background-repeat:repeat-x; font-family:돋움; font-size:12px; color:#ffffff; text-align:left;'>                                                                                    \n");
		contentBase.append("         <td width='100%' background='"+link+"/resources/images/mail/content_c.gif' style='background-repeat:repeat-x; font-family:맑은 고딕; font-size:12px; color:#ffffff; text-align:left;'>                                                                                    \n");
		contentBase.append("          <table border='0' cellpadding='0' cellspacing='0' style='width:100%'>                                                                                                                                                                                      \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
//		contentBase.append("            <td style='color:#ffffff;'>안녕하세요. <strong>"+fromDept+"  "+fromName+"</strong> 입니다.</td>                                                                                                                                                                                       \n");
		contentBase.append("            <td style='color:#ffffff;'></td>                                                                                                                                                                                       \n");
		contentBase.append("            <td align='right' style='color:#ffffff;'>"+date+"</td>                                                                                                                                                                                                                  \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("          </table>                                                                                                                                                                                                                                             \n");
		contentBase.append("         </td>                                                                                                                                                                                                                                                 \n");
		contentBase.append("         <td width='19'><img src='"+link+"/resources/images/mail/content_r_01.gif' width='19' height='46' alt='' /></td>                                                                                                                                                                         \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td height='38'><img src='"+link+"/resources/images/mail/content_l_02.gif' width='19' height='38' alt='' /></td>                                                                                                                                                                        \n");
		contentBase.append("         <td style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; color:#5274ea; text-align:left; line-height:20px;'><strong>"+subSubject+"</strong> 관련하여 사전 안내드립니다. </td>                        \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_02.gif' width='19' height='38' alt='' /></td>                                                                                                                                                                                    \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("          <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style=' background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                \n");
		contentBase.append("         <td  style=' background-repeat:repeat-y; padding-top:20px; padding-bottom:20px; line-height:20px;'><strong style='font-size:12px; color:#5274ea; font-family:맑은 고딕;'>"+contents+"</strong></td>  \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                            \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("          <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style=' background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                \n");
		contentBase.append("         <td  style=' background-repeat:repeat-y; padding-top:20px; padding-bottom:20px; font-size:12px; color:#5274ea; font-family:맑은 고딕; line-height:20px;'><pre>				\n");
		contentBase.append("			<table width='600' border='1' cellpadding='1' cellspacing='1'>			\n");
		contentBase.append("			<tr>																	\n");
		contentBase.append("				<td width='15%' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'><strong>근속기간</strong></td>											\n");
		contentBase.append("				<td width='10%' align='center' style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'><strong>부여 휴가일수</strong></td>											\n");
		contentBase.append("			</tr>																	\n");
		contentBase.append("			<tr>																	\n");
		contentBase.append("				<td align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>10년 근속</td>											\n");
		contentBase.append("				<td align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>2박 3일</td>												\n");
		contentBase.append("			</tr>																	\n");
		contentBase.append("			<tr>																	\n");
		contentBase.append("				<td align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>20년 근속</td>											\n");
		contentBase.append("				<td align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>3박 4일</td>												\n");
		contentBase.append("			</tr>																	\n");
		contentBase.append("			<tr>																	\n");
		contentBase.append("				<td align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>30년 근속</td>											\n");
		contentBase.append("				<td align='center' style=' font-family:맑은 고딕; font-size:12px; text-align:center; line-height:20px;'>4박 5일</td>												\n");
		contentBase.append("			</tr>																	\n");
		contentBase.append("			</table>																\n");
		contentBase.append("		 </pre></td>                                                                \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                            \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");

		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("          <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style=' background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                \n");
		contentBase.append("         <td  style=' background-repeat:repeat-y; padding-top:20px; padding-bottom:20px; line-height:20px;'><strong style='font-size:12px; color:#5274ea; font-family:맑은 고딕;'>"+contents2+"</strong></td>                                     \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                            \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_l_04.gif' width='19' height='128' alt='' /></td>                                                                                                                                                                                   \n");
		contentBase.append("         <td align='left' valign='top' background='"+link+"/resources/images/mail/sign_c.gif' style='background-repeat:repeat-x; text-align:left'>                                                                                                                              \n");
		contentBase.append("          <table width='800' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                       \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td colspan='2'><img src='"+link+"/resources/images/mail/sign_logo_"+cmpn+".gif' width='300' height='50' alt='We build your dream SGC이앤씨' /></td>                                                                                                                             \n");
		contentBase.append("             </tr>                                                                                                                                                                                                                                             \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");		
		contentBase.append("             <td width='36' height='22' align='center' valign='middle'><img src='"+link+"/resources/images/mail/sign_icon.gif' width='13' height='13' alt='' /></td>                                                                                                                             \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>"+fromDept+"&nbsp;&nbsp;&nbsp;"+fromDuty+"&nbsp;&nbsp;"+fromName+"</td>                                                                        \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                                                                                                            \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>전화 : "+fromTel+"&nbsp;&nbsp;&nbsp;</td>                                                                                           \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                                                                                                            \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>E-Mail : "+fromEmail+"</td>                                                                                                    \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("                                                                                                                                                                                                                                                               \n");
		contentBase.append("         </table></td>                                                                                                                                                                                                                                         \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_04.gif' width='19' height='128' alt='' /></td>                                                                                                                                                                                   \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("     </table></td>                                                                                                                                                                                                                                             \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td align='left' valign='bottom' bgcolor='#CCCCCC'><img src='"+link+"/resources/images/mail/copy.gif' width='291' height='28' alt='' /></td>                                                                                                                                                \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append(" </table>                                                                                                                                                                                                                                                      \n");
		contentBase.append(" </div>                                                                                                                                                                                                                                                        \n");
		contentBase.append(" </body> \n");
		contentBase.append(" </html>                                                                                                                                                                                                                                                        \n");
		
		try {
			
			Session session = Session.getInstance(properties, auth);				// Properties 객체와 auth(인증)객체로 메일전송 세션 생성
			MimeMessage msg = new MimeMessage(session);								// 메일 객체를 세션을 통해 생성
			
			InternetAddress[] to_address = {new InternetAddress(toEmail)};			// 받는 사람 메일 주소 객체 생성
			
			InternetAddress addr = new InternetAddress();  
			addr.setPersonal(fromName,"UTF-8");  
			addr.setAddress(fromEmail);
			
			msg.setFrom(addr);							// 보내는 사람 메일주소 설정
			
			msg.setRecipients(Message.RecipientType.TO, to_address);				// 받는 사람 메일 주소를 메일 객체에 매핑
			msg.setContent(contentBase.toString(), "text/html; charset=utf-8");					// 메일 내용을 설정하며 메일 형식을 HTML로 지정
			msg.setSubject(mailSubject,"utf-8");									// 메일 제목 설정
			msg.setSentDate(new Date());											// 보내는 날짜 설정
			
			Transport.send(msg);													// 메일 전송 부분
			
		} catch(MessagingException me) {
		} catch(Exception e) {
		}
	}
    
    //내부결제 SEND메일
    //cmpnCd : 회사코드,  recvAddress : 받는이이메일주소, sendUser : 답변자사번, mailSubject : 메일제목,  subSubject : 메일소제목, mailContent : 메일내용
    public Map<String, String> mailSendApproval(String cmpnCd, String recvAddress, String sendUser, String mailSubject, String subSubject, StringBuffer mailContent){

    	String[] activeProfiles = environment.getActiveProfiles();
    	
    	//local 환경에선 메일 전송 불가
		if(activeProfiles[0].equals("local")) {	
    		return result;
		}
		
		//개발환경 메일 세팅
		if(activeProfiles[0].equals("dev")) {
			recvAddress = "park.sh@sgc.co.kr";	
    		return result;
		}
    	
    	try{
    		//cmpnCd : 회사코드,  recvAddress : 받는이이메일주소, sendUser : 답변자사번, mailSubject : 메일제목,  subSubject : 메일소제목, mailContent : 메일내용
			sendEmailApproval(cmpnCd, recvAddress, sendUser, mailSubject, subSubject, mailContent);
		}catch(Exception e) {
			
        }
    	
    	return result;
    }
    
    //cmpnCd : 회사코드,  mailSubject : 메일제목,  subSubject : 메일소제목, mailContent : 메일내용,  sendUser : 답변자사번, recvAddress : 받는이이메일주소
    public Map<String, String> sendEmailApproval(String cmpnCd, String toEmail, String sendUser, String mailSubject, String subSubject, StringBuffer mailContent) {
    	
    	Date today=new Date();
        SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd");       
        String date = formater.format(today);	//오늘날짜										
        
        Mail mail = new Mail();												
        mail.setCmpnCd(cmpnCd);		//회사코드
        mail.setEmpNo(sendUser);	//답변자사번번호
        
        List<EasyHashMap<String, Object>> mailInfo = mailMapper.selectMailCommList(mail);		//메일 INFO
        String smtpIp 		= (String) mailInfo.get(0).get("esbsCd1");		//메일서버 주소 설정
		String smtpUser 	= (String) mailInfo.get(0).get("esbsCd2");		//SMTP인증 아이디
		String smtpPw 		= (String) mailInfo.get(0).get("esbsCd3");		//SMTP인증 비밀번호
		String link 		= (String) mailInfo.get(0).get("esbsCd4");		//링크
		String cmpn 		= (String) mailInfo.get(0).get("esbsCd5");		//회사구분
		
		/*List<EasyHashMap<String, Object>> userInfo = mailMapper.selectMailUserList(mail);		//답변자 INFO
        String fromEmail 	= (String) userInfo.get(0).get("eMail"); 		//FROM 이메일주소
		String fromName 	= (String) userInfo.get(0).get("empNm"); 		//FROM 사원명
		String fromDuty 	= (String) userInfo.get(0).get("aDuty"); 		//FROM 직급
		String fromDept 	= (String) userInfo.get(0).get("departDeptNm"); //FROM 부서
		String fromTel 		= (String) userInfo.get(0).get("phone"); 		//FROM 전화번호
*/		
		String fromEmail = "hradmin@sgc.co.kr";
		String fromName = "SGC포탈 시스템 관리자";
		String fromDuty = "";
		String fromDept = "본사";
		String fromTel = "02-489-9000";
			
		Properties properties = new Properties();									// Properties 객체 설정
		properties.put("mail.transport.protocol", "smtp");							// SMTP 프로토콜 사용
		properties.put("mail.smtp.host", smtpIp);									// 메일서버 주소 설정
		properties.put("mail.smtp.port", "25");										// 메일서버 포트 설정
		properties.put("mail.smtp.auth", true);										// 인증 사용 여부
		
		SmtpAuth auth = new SmtpAuth(smtpUser, smtpPw);								// SMTP 인증을 위해서 반드시 필요하다
		
		StringBuffer contentBase = new StringBuffer();								// 메일양식 
		contentBase.append(" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'>                                                                                                                                                                                                      \n");
		contentBase.append(" <html xmlns='http://www.w3.org/1999/xhtml'>                                                                                                                                                                                                     \n");
		contentBase.append(" <head> \n");
		contentBase.append(" <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> \n");
		contentBase.append(" <title>SGC이앤씨</title> \n");
		contentBase.append(" </head> \n");
		contentBase.append(" <body> \n");
		contentBase.append(" <div style='padding:10px; border:#CCC solid 1px;'>                                                                                                                                                                                                            \n");
		contentBase.append(" <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                               \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td height='72'>                                                                                                                                                                                                                                          \n");
		contentBase.append("     <table  border='0' cellpadding='0' cellspacing='0' background='"+link+"/resources/images/mail/top_bg.gif' style='width:100%; background-repeat:repeat-x;'>                                                                                                                 \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td height='72' align='left' valign='top'><img src='"+link+"/resources/images/mail/top_logo_"+cmpn+".gif' width='187' height='72' alt='SGC이앤씨' /></td>                                                                                                                            \n");
		contentBase.append("         <td width='100%'>&nbsp;</td>                                                                                                                                                                                                                          \n");
		contentBase.append("         <td align='right' valign='top'></td>                                                                                                                                                           \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("     </table></td>                                                                                                                                                                                                                                             \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td style='padding:20px;'>                                                                                                                                                                                                                                \n");
		contentBase.append("      <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                          \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td width='19' height='46'><img src='"+link+"/resources/images/mail/content_l_01.gif' width='19' height='46' alt='' /></td>                                                                                                                                                             \n");
		contentBase.append("         <td width='100%' background='"+link+"/resources/images/mail/content_c.gif' style='background-repeat:repeat-x; font-family:맑은 고딕; font-size:12px; color:#ffffff; text-align:left;'>                                                                                    \n");
		contentBase.append("          <table border='0' cellpadding='0' cellspacing='0' style='width:100%'>                                                                                                                                                                                      \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		//contentBase.append("            <td style='color:#ffffff;'>안녕하세요. <strong>"+fromDept+"  "+fromName+"</strong> 입니다.</td>                                                                                                                                                                                       \n");
		contentBase.append("            <td align='right' style='color:#ffffff;'>"+date+"</td>                                                                                                                                                                                                                  \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("          </table>                                                                                                                                                                                                                                             \n");
		contentBase.append("         </td>                                                                                                                                                                                                                                                 \n");
		contentBase.append("         <td width='19'><img src='"+link+"/resources/images/mail/content_r_01.gif' width='19' height='46' alt='' /></td>                                                                                                                                                                         \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td height='38'><img src='"+link+"/resources/images/mail/content_l_02.gif' width='19' height='38' alt='' /></td>                                                                                                                                                                        \n");
		contentBase.append("         <td style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; color:#5274ea; text-align:left; line-height:20px;'><strong>"+subSubject+"</strong></td>                        \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_02.gif' width='19' height='38' alt='' /></td>                                                                                                                                                                                    \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style=' background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                \n");
		contentBase.append("         <td  style=' background-repeat:repeat-y; padding-top:20px; padding-bottom:20px; line-height:20px;'><strong style='font-size:12px; color:#5274ea; font-family:맑은 고딕;'>"+mailContent+"</strong></td>                                     \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                            \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style='background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                      \n");
		contentBase.append("         <td align='center' valign='middle' style='padding-top:15px; padding-bottom:15px; border-top:#CCC solid 1px;'><a href='https://portal.sgc.co.kr/websquare/'><img src='"+link+"/resources/images/mail/btn_site.gif' alt='사이트접속하기' width='145' height='28' border='0' /></a></td>                              \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                                     \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_l_04.gif' width='19' height='128' alt='' /></td>                                                                                                                                                                                   \n");
		contentBase.append("         <td align='left' valign='top' background='"+link+"/resources/images/mail/sign_c.gif' style='background-repeat:repeat-x; text-align:left'>                                                                                                                              \n");
		contentBase.append("          <table width='800' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                       \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td colspan='2'><img src='"+link+"/resources/images/mail/sign_logo_"+cmpn+".gif' width='300' height='50' alt='We build your dream SGC이앤씨' /></td>                                                                                                                             \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                             \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22' align='center' valign='middle'><img src='"+link+"/resources/images/mail/sign_icon.gif' width='13' height='13' alt='' /></td>                                                                                                                             \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>"+fromDept+"&nbsp;&nbsp;&nbsp;"+fromDuty+"&nbsp;&nbsp;"+fromName+"</td>                                                                        \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                                                                                                            \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>전화 : "+fromTel+"&nbsp;&nbsp;&nbsp;</td>                                                                                           \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                                                                                                            \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>E-Mail : "+fromEmail+"</td>                                                                                                    \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("                                                                                                                                                                                                                                                               \n");
		contentBase.append("         </table></td>                                                                                                                                                                                                                                         \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_04.gif' width='19' height='128' alt='' /></td>                                                                                                                                                                                   \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("     </table></td>                                                                                                                                                                                                                                             \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td align='left' valign='bottom' bgcolor='#CCCCCC'><img src='"+link+"/resources/images/mail/copy.gif' width='291' height='28' alt='' /></td>                                                                                                                                                \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append(" </table>                                                                                                                                                                                                                                                      \n");
		contentBase.append(" </div>                                                                                                                                                                                                                                                        \n");
		contentBase.append(" </body> \n");
		contentBase.append(" </html>                                                                                                                                                                                                                                                        \n");
    
		try {
			
			Session session = Session.getInstance(properties, auth);				// Properties 객체와 (인증)auth객체로 메일전송 세션 생성
			MimeMessage msg = new MimeMessage(session);								// 메일 객체를 세션을 통해 생성
			
			InternetAddress[] to_address = {new InternetAddress(toEmail)};			// 받는 사람 메일 주소 객체 생성
			msg.setFrom(new InternetAddress(fromEmail));							// 보내는 사람 메일주소 설정
			msg.setRecipients(Message.RecipientType.TO, to_address);				// 받는 사람 메일 주소를 메일 객체에 매핑
			msg.setContent(contentBase.toString(), "text/html; charset=utf-8");		// 메일 내용을 설정하며 메일 형식을 HTML로 지정
			msg.setSubject(mailSubject,"utf-8");									// 메일 제목 설정
			msg.setSentDate(new Date());											// 보내는 날짜 설정
			System.out.print(msg.getContent());
			Transport.send(msg);													// 메일 전송 부분
			
			result.put("fromEmail", fromEmail.toString());
			result.put("contentBase", contentBase.toString());
			
		} catch(MessagingException me) {
		} catch(Exception e) {
		}
		return result;
    }
    
    //SEND메일 - 하자 작업지시서
    public Map<String, String> mailSendWorkOrder(String cmpnCd, String mailSubject, String subSubject, StringBuffer mailContent, String sendUser, String recvAddress){
    	
    	String[] activeProfiles = environment.getActiveProfiles();
    	
    	//local 환경에선 메일 전송 불가
		if(activeProfiles[0].equals("local")) {			
			return result;
		}
		//개발환경 메일 세팅
		if(activeProfiles[0].equals("dev")) {
			recvAddress = "park.sh@sgc.co.kr";
			return result;
		}
    	
    	try{
    		//cmpnCd : 회사코드,  recvAddress : 받는이이메일주소, sendUser : 답변자사번, mailSubject : 메일제목,  subSubject : 메일소제목, mailContent : 메일내용
    		sendEmailWorkOrder(cmpnCd, recvAddress, sendUser, mailSubject, subSubject, mailContent);
		}catch(Exception e) {
        }
    	
    	return result;
		
    }
    
    //cmpnCd : 회사코드, recvAddress : 받는이이메일주소,  sendUser : 답변자사번,  mailSubject : 메일제목,  subSubject : 메일소제목, mailContent : 메일내용
    public Map<String, String> sendEmailWorkOrder(String cmpnCd, String recvAddress, String sendUser, String mailSubject, String subSubject, StringBuffer mailContent) {

    	Date today=new Date();
        SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd");       
        String date = formater.format(today);			//오늘날짜										
        
        Mail mail = new Mail();												
        mail.setCmpnCd(cmpnCd);							//회사코드
        mail.setEmpNo(sendUser);						//답변자사번번호
        
        List<EasyHashMap<String, Object>> mailInfo = mailMapper.selectMailCommList(mail);		//메일 INFO
        String smtpIp 	= (String) mailInfo.get(0).get("esbsCd1");		// 메일서버 주소 설정
		String smtpUser = (String) mailInfo.get(0).get("esbsCd2");		// SMTP인증 아이디
		String smtpPw 	= (String) mailInfo.get(0).get("esbsCd3");		// SMTP인증 비밀번호
		String link 	= (String) mailInfo.get(0).get("esbsCd4");		// 링크
		String cmpn 	= (String) mailInfo.get(0).get("esbsCd5");		// 회사구분
        
		List<EasyHashMap<String, Object>> userInfo = mailMapper.selectMailUserList(mail);		//답변자 INFO
        String fromEmail 	= (String) userInfo.get(0).get("eMail");		//FROM 이메일주소
		String fromName 	= (String) userInfo.get(0).get("empNm");		//FROM 사원명
		String fromDuty 	= (String) userInfo.get(0).get("aDuty");		//FROM 직급
		String fromDept 	= (String) userInfo.get(0).get("departDeptNm");	//FROM 부서
		String fromTel 		= (String) userInfo.get(0).get("phone"); 		//FROM 전화번호											//FROM 전화번호
			
		Properties properties = new Properties();									// Properties 객체 설정
		properties.put("mail.transport.protocol", "smtp");							// SMTP 프로토콜 사용
		properties.put("mail.smtp.host", smtpIp);									// 메일서버 주소 설정
		properties.put("mail.smtp.port", "25");										// 메일서버 포트 설정
		properties.put("mail.smtp.auth", true);										// 인증 사용 여부
		
		SmtpAuth auth = new SmtpAuth(smtpUser, smtpPw);								// SMTP 인증을 위해서 반드시 필요하다
		
		StringBuffer contentBase = new StringBuffer();								// 메일양식 
		contentBase.append(" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> \n");
		contentBase.append(" <html xmlns='http://www.w3.org/1999/xhtml'> \n");
		contentBase.append(" <head> \n");
		contentBase.append(" <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> \n");
		contentBase.append(" <title>SGC이앤씨</title> \n");
		contentBase.append(" </head> \n");
		contentBase.append(" <body> \n");
		contentBase.append(" <div style='padding:10px; border:#CCC solid 1px;'>                                                                                                                                                                                                            \n");
		contentBase.append(" <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                               \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td height='72'>                                                                                                                                                                                                                                          \n");
		contentBase.append("     <table  border='0' cellpadding='0' cellspacing='0' background='"+link+"/resources/images/mail/top_bg.gif' style='width:100%; background-repeat:repeat-x;'>                                                                                                \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td height='72' align='left' valign='top'><img src='"+link+"/resources/images/mail/top_logo_"+cmpn+".gif' width='187' height='72' alt='SGC이앤씨' /></td>                                                                                            \n");
		contentBase.append("         <td width='100%'>&nbsp;</td>                                                                                                                                                                                                                          \n");
		contentBase.append("         <td align='right' valign='top'></td>                                                                                                                                                           \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("     </table></td>                                                                                                                                                                                                                                             \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td style='padding:20px;'>                                                                                                                                                                                                                                \n");
		contentBase.append("      <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                          \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td width='19' height='46'><img src='"+link+"/resources/images/mail/content_l_01.gif' width='19' height='46' alt='' /></td>                                                                                                                           \n");
//		contentBase.append("         <td width='100%' style=' background-image:url("+link+"/resources/images/mail/content_c.gif); background-repeat:repeat-x; font-family:돋움; font-size:12px; color:#ffffff; text-align:left;'>                                                           \n");
		contentBase.append("         <td width='100%' background='"+link+"/resources/images/mail/content_c.gif' style='background-repeat:repeat-x; font-family:맑은 고딕; font-size:12px; color:#ffffff; text-align:left;'>                                                                     \n");
		contentBase.append("          <table border='0' cellpadding='0' cellspacing='0' style='width:100%'>                                                                                                                                                                                      \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("            <td style='color:#ffffff;'>안녕하세요. <strong>"+fromDept+"  "+fromName+"</strong> 입니다.</td>                                                                                                                                                         \n");
		contentBase.append("            <td align='right' style='color:#ffffff;'>"+date+"</td>                                                                                                                                                                                             \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("          </table>                                                                                                                                                                                                                                             \n");
		contentBase.append("         </td>                                                                                                                                                                                                                                                 \n");
		contentBase.append("         <td width='19'><img src='"+link+"/resources/images/mail/content_r_01.gif' width='19' height='46' alt='' /></td>                                                                                                                                       \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td height='38'><img src='"+link+"/resources/images/mail/content_l_02.gif' width='19' height='38' alt='' /></td>                                                                                                                                      \n");
		contentBase.append("         <td style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; color:#5274ea; text-align:left; line-height:20px;'><strong>"+subSubject+"</strong> 관련하여 메일 보내드리오니 확인  바랍니다. </td>                        \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_02.gif' width='19' height='38' alt='' /></td>                                                                                                                                                  \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style=' background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                \n");
		contentBase.append("         <td  style=' background-repeat:repeat-y; padding-top:20px; padding-bottom:20px; line-height:20px;'><strong style='font-size:12px; color:#5274ea; font-family:맑은 고딕;'>"+mailContent+"</strong></td>                                     \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                       \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style='background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                  \n");
		contentBase.append("         <td align='center' valign='middle' style='padding-top:15px; padding-bottom:15px; border-top:#CCC solid 1px;'><a href='https://as.sgcenc.co.kr/'><img src='"+link+"/resources/images/mail/btn_site.gif' alt='사이트접속하기' width='145' height='28' border='0' /></a></td> \n");
		contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                       \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_l_04.gif' width='19' height='128' alt='' /></td>                                                                                                                                                 \n");
		contentBase.append("         <td align='left' valign='top' background='"+link+"/resources/images/mail/sign_c.gif' style='background-repeat:repeat-x; text-align:left'>                                                                                                             \n");
		contentBase.append("          <table width='800' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                       \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td colspan='2'><img src='"+link+"/resources/images/mail/sign_logo_"+cmpn+".gif' width='300' height='50' alt='We build your dream SGC이앤씨' /></td>                                                                                             \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                             \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22' align='center' valign='middle'><img src='"+link+"/resources/images/mail/sign_icon.gif' width='13' height='13' alt='' /></td>                                                                                           \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>"+fromDept+"&nbsp;&nbsp;&nbsp;"+fromDuty+"&nbsp;&nbsp;"+fromName+"</td>                                                                        \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                                                                                                            \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>전화 : "+fromTel+"&nbsp;&nbsp;&nbsp;</td>                                                                                           \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
		contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                                                                                                            \n");
		contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>E-Mail : "+fromEmail+"</td>                                                                                                    \n");
		contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
		contentBase.append("                                                                                                                                                                                                                                                               \n");
		contentBase.append("         </table></td>                                                                                                                                                                                                                                         \n");
		contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_04.gif' width='19' height='128' alt='' /></td>                                                                                                                                                 \n");
		contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
		contentBase.append("     </table></td>                                                                                                                                                                                                                                             \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
		contentBase.append("     <td align='left' valign='bottom' bgcolor='#CCCCCC'><img src='"+link+"/resources/images/mail/copy.gif' width='291' height='28' alt='' /></td>                                                                                                              \n");
		contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
		contentBase.append(" </table>                                                                                                                                                                                                                                                      \n");
		contentBase.append(" </div>                                                                                                                                                                                                                                                        \n");
		contentBase.append(" </body> \n");
		contentBase.append(" </html>                                                                                                                                                                                                                                                        \n");

		try {
			
			Session session = Session.getInstance(properties, auth);				// Properties 객체와 (인증)auth객체로 메일전송 세션 생성
			MimeMessage msg = new MimeMessage(session);								// 메일 객체를 세션을 통해 생성
			
			//작업지시서 메일 전송
			InternetAddress[] to_address = {new InternetAddress(recvAddress)};		// 받는 사람 메일 주소 객체 생성
			msg.setFrom(new InternetAddress(fromEmail));							// 보내는 사람 메일주소 설정
			msg.setRecipients(Message.RecipientType.TO, to_address);				// 받는 사람 메일 주소를 메일 객체에 매핑
			msg.setContent(contentBase.toString(), "text/html; charset=utf-8");		// 메일 내용을 설정하며 메일 형식을 HTML로 지정
			msg.setSubject(mailSubject,"utf-8");									// 메일 제목 설정
			msg.setSentDate(new Date());											// 보내는 날짜 설정
			Transport.send(msg);													// 메일 전송 부분
			
			//작업지시서 메일 전송
			InternetAddress[] to_addressReturn = {new InternetAddress(fromEmail)};		// 받는 사람 메일 주소 객체 생성
			msg.setFrom(new InternetAddress(fromEmail));							// 보내는 사람 메일주소 설정
			msg.setRecipients(Message.RecipientType.TO, to_addressReturn);				// 받는 사람 메일 주소를 메일 객체에 매핑
			msg.setContent(contentBase.toString(), "text/html; charset=utf-8");		// 메일 내용을 설정하며 메일 형식을 HTML로 지정
			msg.setSubject(mailSubject,"utf-8");									// 메일 제목 설정
			msg.setSentDate(new Date());											// 보내는 날짜 설정
			Transport.send(msg);													// 메일 전송 부분
			
			result.put("fromEmail", fromEmail.toString());
			result.put("contentBase", contentBase.toString());
			
		} catch(MessagingException me) {
		} catch(Exception e) {
		}
		return result;
    }
    
    //SEND메일 - 하자 작업지시서 공유
    public Map<String, String> mailSendWorkShare(String cmpnCd, String mailSubject, String subSubject, StringBuffer mailContent, String sendUser, String recvAddress){
    	
    	String[] activeProfiles = environment.getActiveProfiles();
    	
    	//local 환경에선 메일 전송 불가
    	if(activeProfiles[0].equals("local")) {			
    		return result;
    	}
    	//개발환경 메일 세팅
    	if(activeProfiles[0].equals("dev")) {
    		//recvAddress = "sbk8111@sdcit.co.kr";
    		return result;
    	}
    	
    	try{
    		//cmpnCd : 회사코드,  recvAddress : 받는이이메일주소, sendUser : 답변자사번, mailSubject : 메일제목,  subSubject : 메일소제목, mailContent : 메일내용
    		sendEmailWorkShare(cmpnCd, recvAddress, sendUser, mailSubject, subSubject, mailContent);
    	}catch(Exception e) {
    	}
    	
    	return result;
    	
    }
    
    //cmpnCd : 회사코드, recvAddress : 받는이이메일주소,  sendUser : 답변자사번,  mailSubject : 메일제목,  subSubject : 메일소제목, mailContent : 메일내용
    public Map<String, String> sendEmailWorkShare(String cmpnCd, String recvAddress, String sendUser, String mailSubject, String subSubject, StringBuffer mailContent) {
    	
    	Date today=new Date();
    	SimpleDateFormat formater = new SimpleDateFormat("yyyy-MM-dd");       
    	String date = formater.format(today);			//오늘날짜										
    	
    	Mail mail = new Mail();												
    	mail.setCmpnCd(cmpnCd);							//회사코드
    	mail.setEmpNo(sendUser);						//답변자사번번호
    	
    	List<EasyHashMap<String, Object>> mailInfo = mailMapper.selectMailCommList(mail);		//메일 INFO
    	String smtpIp 	= (String) mailInfo.get(0).get("esbsCd1");		// 메일서버 주소 설정
    	String smtpUser = (String) mailInfo.get(0).get("esbsCd2");		// SMTP인증 아이디
    	String smtpPw 	= (String) mailInfo.get(0).get("esbsCd3");		// SMTP인증 비밀번호
    	String link 	= (String) mailInfo.get(0).get("esbsCd4");		// 링크
    	String cmpn 	= (String) mailInfo.get(0).get("esbsCd5");		// 회사구분
    	
    	List<EasyHashMap<String, Object>> userInfo = mailMapper.selectMailUserList(mail);		//답변자 INFO
    	String fromEmail 	= (String) userInfo.get(0).get("eMail");		//FROM 이메일주소
    	String fromName 	= (String) userInfo.get(0).get("empNm");		//FROM 사원명
    	String fromDuty 	= (String) userInfo.get(0).get("aDuty");		//FROM 직급
    	String fromDept 	= (String) userInfo.get(0).get("departDeptNm");	//FROM 부서
    	String fromTel 		= (String) userInfo.get(0).get("phone"); 		//FROM 전화번호											//FROM 전화번호
    	
    	Properties properties = new Properties();									// Properties 객체 설정
    	properties.put("mail.transport.protocol", "smtp");							// SMTP 프로토콜 사용
    	properties.put("mail.smtp.host", smtpIp);									// 메일서버 주소 설정
    	properties.put("mail.smtp.port", "25");										// 메일서버 포트 설정
    	properties.put("mail.smtp.auth", true);										// 인증 사용 여부
    	
    	SmtpAuth auth = new SmtpAuth(smtpUser, smtpPw);								// SMTP 인증을 위해서 반드시 필요하다
    	
    	StringBuffer contentBase = new StringBuffer();								// 메일양식 
    	contentBase.append(" <!DOCTYPE html PUBLIC '-//W3C//DTD XHTML 1.0 Transitional//EN' 'http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd'> \n");
    	contentBase.append(" <html xmlns='http://www.w3.org/1999/xhtml'> \n");
    	contentBase.append(" <head> \n");
    	contentBase.append(" <meta http-equiv='Content-Type' content='text/html; charset=utf-8' /> \n");
    	contentBase.append(" <title>SGC이앤씨</title> \n");
    	contentBase.append(" </head> \n");
    	contentBase.append(" <body> \n");
    	contentBase.append(" <div style='padding:10px; border:#CCC solid 1px;'>                                                                                                                                                                                                            \n");
    	contentBase.append(" <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                               \n");
    	contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
    	contentBase.append("     <td height='72'>                                                                                                                                                                                                                                          \n");
    	contentBase.append("     <table  border='0' cellpadding='0' cellspacing='0' background='"+link+"/resources/images/mail/top_bg.gif' style='width:100%; background-repeat:repeat-x;'>                                                                                                \n");
    	contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
    	contentBase.append("         <td height='72' align='left' valign='top'><img src='"+link+"/resources/images/mail/top_logo_"+cmpn+".gif' width='187' height='72' alt='SGC이앤씨' /></td>                                                                                            \n");
    	contentBase.append("         <td width='100%'>&nbsp;</td>                                                                                                                                                                                                                          \n");
    	contentBase.append("         <td align='right' valign='top'></td>                                                                                                                                                           \n");
    	contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
    	contentBase.append("     </table></td>                                                                                                                                                                                                                                             \n");
    	contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
    	contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
    	contentBase.append("     <td style='padding:20px;'>                                                                                                                                                                                                                                \n");
    	contentBase.append("      <table style='width:100%' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                          \n");
    	contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
    	contentBase.append("         <td width='19' height='46'><img src='"+link+"/resources/images/mail/content_l_01.gif' width='19' height='46' alt='' /></td>                                                                                                                           \n");
//		contentBase.append("         <td width='100%' style=' background-image:url("+link+"/resources/images/mail/content_c.gif); background-repeat:repeat-x; font-family:돋움; font-size:12px; color:#ffffff; text-align:left;'>                                                           \n");
    	contentBase.append("         <td width='100%' background='"+link+"/resources/images/mail/content_c.gif' style='background-repeat:repeat-x; font-family:맑은 고딕; font-size:12px; color:#ffffff; text-align:left;'>                                                                     \n");
    	contentBase.append("          <table border='0' cellpadding='0' cellspacing='0' style='width:100%'>                                                                                                                                                                                      \n");
    	contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
    	contentBase.append("            <td style='color:#ffffff;'>안녕하세요. <strong>"+fromDept+"  "+fromName+"</strong> 입니다.</td>                                                                                                                                                         \n");
    	contentBase.append("            <td align='right' style='color:#ffffff;'>"+date+"</td>                                                                                                                                                                                             \n");
    	contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
    	contentBase.append("          </table>                                                                                                                                                                                                                                             \n");
    	contentBase.append("         </td>                                                                                                                                                                                                                                                 \n");
    	contentBase.append("         <td width='19'><img src='"+link+"/resources/images/mail/content_r_01.gif' width='19' height='46' alt='' /></td>                                                                                                                                       \n");
    	contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
    	contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
    	contentBase.append("         <td height='38'><img src='"+link+"/resources/images/mail/content_l_02.gif' width='19' height='38' alt='' /></td>                                                                                                                                      \n");
    	contentBase.append("         <td style=' background-color:#EFEFEF; font-family:맑은 고딕; font-size:12px; color:#5274ea; text-align:left; line-height:20px;'><strong>"+subSubject+"</strong> 관련하여 메일 보내드리오니 확인  바랍니다. </td>                        \n");
    	contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_02.gif' width='19' height='38' alt='' /></td>                                                                                                                                                  \n");
    	contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
    	contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
    	contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style=' background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                \n");
		contentBase.append("         <td  style=' background-repeat:repeat-y; padding-top:20px; padding-bottom:20px; line-height:20px;'><strong style='font-size:12px; color:#5274ea; font-family:맑은 고딕;'>"+mailContent+"</strong></td>                                     \n");
    	contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                       \n");
    	contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
    	contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
    	contentBase.append("         <td background='"+link+"/resources/images/mail/content_l_02_new.gif' style='background-repeat:repeat-y;'>&nbsp;</td>                                                                                                                                  \n");
    	contentBase.append("         <td align='center' valign='middle' style='padding-top:15px; padding-bottom:15px; border-top:#CCC solid 1px;'><a href='https://portal.sgc.co.kr/'><img src='"+link+"/resources/images/mail/btn_site.gif' alt='사이트접속하기' width='145' height='28' border='0' /></a></td> \n");
    	contentBase.append("         <td background='"+link+"/resources/images/mail/content_r_02_new.gif' style='background-color:#EFEFEF;  background-repeat:repeat-y;'>&nbsp;</td>                                                                                                       \n");
    	contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
    	contentBase.append("       <tr>                                                                                                                                                                                                                                                    \n");
    	contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_l_04.gif' width='19' height='128' alt='' /></td>                                                                                                                                                 \n");
    	contentBase.append("         <td align='left' valign='top' background='"+link+"/resources/images/mail/sign_c.gif' style='background-repeat:repeat-x; text-align:left'>                                                                                                             \n");
    	contentBase.append("          <table width='800' border='0' cellpadding='0' cellspacing='0'>                                                                                                                                                                                       \n");
    	contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
    	contentBase.append("             <td colspan='2'><img src='"+link+"/resources/images/mail/sign_logo_"+cmpn+".gif' width='300' height='50' alt='We build your dream SGC이앤씨' /></td>                                                                                             \n");
    	contentBase.append("           </tr>                                                                                                                                                                                                                                             \n");
    	contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
    	contentBase.append("             <td width='36' height='22' align='center' valign='middle'><img src='"+link+"/resources/images/mail/sign_icon.gif' width='13' height='13' alt='' /></td>                                                                                           \n");
    	contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>"+fromDept+"&nbsp;&nbsp;&nbsp;"+fromDuty+"&nbsp;&nbsp;"+fromName+"</td>                                                                        \n");
    	contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
    	contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
    	contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                                                                                                            \n");
    	contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>전화 : "+fromTel+"&nbsp;&nbsp;&nbsp;</td>                                                                                           \n");
    	contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
    	contentBase.append("           <tr>                                                                                                                                                                                                                                                \n");
    	contentBase.append("             <td width='36' height='22'>&nbsp;</td>                                                                                                                                                                                                            \n");
    	contentBase.append("             <td width='*' style='font-size:12px; color:#676767; font-family:맑은 고딕; line-height:20px;'>E-Mail : "+fromEmail+"</td>                                                                                                    \n");
    	contentBase.append("           </tr>                                                                                                                                                                                                                                               \n");
    	contentBase.append("                                                                                                                                                                                                                                                               \n");
    	contentBase.append("         </table></td>                                                                                                                                                                                                                                         \n");
    	contentBase.append("         <td><img src='"+link+"/resources/images/mail/content_r_04.gif' width='19' height='128' alt='' /></td>                                                                                                                                                 \n");
    	contentBase.append("       </tr>                                                                                                                                                                                                                                                   \n");
    	contentBase.append("     </table></td>                                                                                                                                                                                                                                             \n");
    	contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
    	contentBase.append("   <tr>                                                                                                                                                                                                                                                        \n");
    	contentBase.append("     <td align='left' valign='bottom' bgcolor='#CCCCCC'><img src='"+link+"/resources/images/mail/copy.gif' width='291' height='28' alt='' /></td>                                                                                                              \n");
    	contentBase.append("   </tr>                                                                                                                                                                                                                                                       \n");
    	contentBase.append(" </table>                                                                                                                                                                                                                                                      \n");
    	contentBase.append(" </div>                                                                                                                                                                                                                                                        \n");
    	contentBase.append(" </body> \n");
    	contentBase.append(" </html>                                                                                                                                                                                                                                                        \n");
    	
    	try {
    		
    		Session session = Session.getInstance(properties, auth);				// Properties 객체와 (인증)auth객체로 메일전송 세션 생성
    		MimeMessage msg = new MimeMessage(session);								// 메일 객체를 세션을 통해 생성
    		
    		//작업지시서 메일 전송
    		InternetAddress[] to_address = {new InternetAddress(recvAddress)};		// 받는 사람 메일 주소 객체 생성
    		msg.setFrom(new InternetAddress(fromEmail));							// 보내는 사람 메일주소 설정
    		msg.setRecipients(Message.RecipientType.TO, to_address);				// 받는 사람 메일 주소를 메일 객체에 매핑
    		msg.setContent(contentBase.toString(), "text/html; charset=utf-8");		// 메일 내용을 설정하며 메일 형식을 HTML로 지정
    		msg.setSubject(mailSubject,"utf-8");									// 메일 제목 설정
    		msg.setSentDate(new Date());											// 보내는 날짜 설정
    		Transport.send(msg);													// 메일 전송 부분
    		
    		result.put("fromEmail", fromEmail.toString());
    		result.put("contentBase", contentBase.toString());
    		
    	} catch(MessagingException me) {
    	} catch(Exception e) {
    	}
    	return result;
    }
}