Trigger
trigger CreateQuoteDocSignComp12 on dsfs__DocuSign_Status__c(after insert,after update){
List<Messaging.SingleEmailMessage> sendMails = new List<Messaging.SingleEmailMessage>();
List<Messaging.EmailFileAttachment> attachmentList = new List<Messaging.EmailFileAttachment>();
set<Id> docusignID = new set<Id>();
for(dsfs__DocuSign_Status__c dsfs : trigger.new){
if(dsfs.dsfs__Envelope_Status__c == 'Completed'){
docusignID.add(dsfs.ID);
}
}
system.debug('@@@@@@@@@@@@'+docusignID);
user currentUserID = [select id,email from user where id=:userinfo.getuserid()];
list<string> UserEmail = new list<string>();
UserEmail.add(currentUserID.Email);
list<string> email = new list<string>();
email.add(currentUserID.email);
system.debug('#######################'+email);
for( Attachment att : [ Select Id, Parentid, Body, Name from attachment where parentid IN: docusignID ]) {
system.debug('22222222222222'+att);
system.debug('888888888888'+email);
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName(att.Name);
efa.setBody(att.body);
efa.setInline(false);
attachmentList.add(efa);
Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();
singleMail.setToAddresses(email);
singleMail.setTargetObjectId(currentUserID.ID);
singleMail.setSaveAsActivity(false);
singleMail.setTreatTargetObjectAsRecipient(false);
singleMail.setPlainTextBody('Your Email has been sent');
singleMail.setFileAttachments(attachmentList);
sendMails.add(singleMail);
}
//Messaging.sendEmail(sendMails);
}
trigger CreateQuoteDocSignComp12 on dsfs__DocuSign_Status__c(after insert,after update){
List<Messaging.SingleEmailMessage> sendMails = new List<Messaging.SingleEmailMessage>();
List<Messaging.EmailFileAttachment> attachmentList = new List<Messaging.EmailFileAttachment>();
set<Id> docusignID = new set<Id>();
for(dsfs__DocuSign_Status__c dsfs : trigger.new){
if(dsfs.dsfs__Envelope_Status__c == 'Completed'){
docusignID.add(dsfs.ID);
}
}
system.debug('@@@@@@@@@@@@'+docusignID);
user currentUserID = [select id,email from user where id=:userinfo.getuserid()];
list<string> UserEmail = new list<string>();
UserEmail.add(currentUserID.Email);
list<string> email = new list<string>();
email.add(currentUserID.email);
system.debug('#######################'+email);
for( Attachment att : [ Select Id, Parentid, Body, Name from attachment where parentid IN: docusignID ]) {
system.debug('22222222222222'+att);
system.debug('888888888888'+email);
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName(att.Name);
efa.setBody(att.body);
efa.setInline(false);
attachmentList.add(efa);
Messaging.SingleEmailMessage singleMail = new Messaging.SingleEmailMessage();
singleMail.setToAddresses(email);
singleMail.setTargetObjectId(currentUserID.ID);
singleMail.setSaveAsActivity(false);
singleMail.setTreatTargetObjectAsRecipient(false);
singleMail.setPlainTextBody('Your Email has been sent');
singleMail.setFileAttachments(attachmentList);
sendMails.add(singleMail);
}
//Messaging.sendEmail(sendMails);
}