| | |
| | | public without sharing class SendEmailController { |
| | | public without sharing class SendEmailController{ |
| | | |
| | | public Mail_Merge__c mail{get; set;} |
| | | |
| | |
| | | public Attachment attachment{get;set;} |
| | | |
| | | public List<Attachment> attachmentList{get;set;} |
| | | public List<FileAddress__c> newAttachmentList{get;set;} |
| | | |
| | | //SWO_Email_Member__c 这个对象只是为了生成页面上的人员明细行 |
| | | // public List<SWO_Email_Member__c> lineDataList_new{get;set;} |
| | |
| | | public List<String> ccAddresses ; |
| | | public List<String> bccAddresses ; |
| | | |
| | | public String AWSDataId{get;set;} |
| | | public String staticResourceMail{get;set;} |
| | | public String staticResourceMailMerge{get;set;} |
| | | public String staticResourceDocument{get;set;} |
| | | public SendEmailController() { |
| | | id = System.currentPageReference().getParameters().get('id'); |
| | | type = System.currentPageReference().getParameters().get('type'); |
| | | typeid = System.currentPageReference().getParameters().get('typeid'); |
| | | openType = System.currentPageReference().getParameters().get('openType'); |
| | | staticResourceMail = JSON.serialize(PIHelper.getPIIntegrationInfo('Mail')); |
| | | staticResourceMailMerge = JSON.serialize(PIHelper.getPIIntegrationInfo('Mail_Merge__c')); |
| | | staticResourceDocument = JSON.serialize(PIHelper.getPIIntegrationInfo('Document')); |
| | | } |
| | | |
| | | public SendEmailController(ApexPages.StandardController stdController) { |
| | | id = System.currentPageReference().getParameters().get('id'); |
| | | type = System.currentPageReference().getParameters().get('type'); |
| | | typeid = System.currentPageReference().getParameters().get('typeid'); |
| | | openType = System.currentPageReference().getParameters().get('openType'); |
| | | public SendEmailController(ApexPages.StandardController controller) { |
| | | // 20220318 PI 改造 By Bright start |
| | | // id = System.currentPageReference().getParameters().get('id'); |
| | | // type = System.currentPageReference().getParameters().get('type'); |
| | | // typeid = System.currentPageReference().getParameters().get('typeid'); |
| | | // openType = System.currentPageReference().getParameters().get('openType'); |
| | | this(); |
| | | // 20220318 PI 改造 By Bright end |
| | | } |
| | | |
| | | public void init(){ |
| | |
| | | mail.RECORD__c = typeid; |
| | | mail.RECORD_TYPE__c = type; |
| | | memberLineDatas = new List<MemberLine>(); |
| | | |
| | | if (!string.isBlank(typeid)) { |
| | | Id rid = typeid; |
| | | String sobjname = 'User_FaultInfo__c'; |
| | | sobjname = rid.getSobjectType().getDescribe().getName(); |
| | | List<sobject> lso = Database.query('select id,name from '+sobjname+' where id = :rid'); |
| | | System.debug('lso='+lso); |
| | | if (lso.size()>0) { |
| | | name = sobjname.replace('__c','')+':'+lso[0].get('Name'); |
| | | if (sobjname == 'User_FaultInfo__c') { |
| | | name = 'Case:'+lso[0].get('Name'); |
| | | } |
| | | } |
| | | System.debug('name='+name); |
| | | } |
| | | |
| | | |
| | | if(id == null){ |
| | | isOnClick = false; |
| | | mail.FROM__c = UserInfo.getUserEmail(); |
| | |
| | | } |
| | | } |
| | | }else{ |
| | | mail = [select id,send__c,MESSAGE__c,SUBJECT__c,TYPE__c,FROM__c,DATE__c,RECIPIENT__c,CC__c,BCC__c,RECORD__c,RECORD_TYPE__c,toName__c,ccName__c,bccName__c,ALL_MEMBER__c,ALL_MEMBER_NAME__c,ALL_MEMBER_TYPE__c,EMAIL_SENT__c,SWO__c,CaseF__c,Quotes__c from Mail_Merge__c where id =:id]; |
| | | |
| | | |
| | | mail = [select id,send__c,MESSAGE__c,SUBJECT__c,TYPE__c,FROM__c,DATE__c,RECIPIENT__c,CC__c,BCC__c,RECORD__c,RECORD_TYPE__c,toName__c,ccName__c,bccName__c,ALL_MEMBER__c,ALL_MEMBER_NAME__c,ALL_MEMBER_TYPE__c,EMAIL_SENT__c,SWO__c,CaseF__c,Quotes__c, |
| | | AWS_Data_Id__c // 20220222 PI改造 by Brigh |
| | | from Mail_Merge__c where id =:id]; |
| | | AWSDataId=mail.AWS_Data_Id__c; |
| | | //mail.TYPE__c == 'reply' 邮件为回复邮件 或者是系统自动发送的邮件 |
| | | //EMAIL_SENT__c =='YES' 邮件已发送 |
| | | if(mail.TYPE__c == 'reply' || mail.EMAIL_SENT__c =='YES'){ |
| | |
| | | replyEmailHead = '\n\n\n\n'; |
| | | replyEmailHead += '-------------邮件原件--------------\n'; |
| | | replyEmailHead += '发件人:' + mail.FROM__c + ';\n'; |
| | | replyEmailHead += '发件时间:' + mail.DATE__c.addHours(8) + ';\n'; |
| | | replyEmailHead += '发件时间:' + (mail.DATE__c==null?Datetime.now():mail.DATE__c.addHours(8)) + ';\n'; |
| | | replyEmailHead += '收件人:' + mailToAddressName + '\n'; |
| | | replyEmailHead += '抄送:' + mailCcAdressName + '\n'; |
| | | replyEmailHead += '主题:' + mail.SUBJECT__c + ';\n\n'; |
| | |
| | | addLine(); |
| | | } |
| | | attachmentList = [select Id,Name,CreatedDate,BodyLength,Body from Attachment where ParentId=:id]; |
| | | newAttachmentList = [select Id,CreatedDate,Name,ViewLink__c,AWS_File_Key__c,FileName__c from FileAddress__c where ParentRecordId__c=:id]; |
| | | /*if(String.isNotBlank(openType) && openType == 'Reply'){ |
| | | attachmentList.clear(); |
| | | }*/ |
| | |
| | | } |
| | | } |
| | | mail.EMAIL_SENT__c = 'YES'; |
| | | System.debug('mail='+mail); |
| | | upsert mail; |
| | | // 返回点击邮件页面 |
| | | PageReference ref = new Pagereference('/'+mail.RECORD__c+'?type=mail'); |
| | |
| | | } |
| | | |
| | | public void save() { |
| | | System.debug('handleType='+handleType); |
| | | toAddresses = new List<String>(); |
| | | ccAddresses = new List<String>(); |
| | | bccAddresses = new List<String>(); |