How to Send Echo Document Sign with apex code in saleforce
I want to send echo sign document on custom button using apex code.
Document has been send but main issue is that mail not send with proper format, as per standard.
I did not get any link for sign the document.
Please provide me API name by which we can implement this one
My Code is
public class SendAgreementDocument {
public void SendPdf()
{
echosign_dev1__SIGN_Agreement__c agmt = new echosign_dev1__SIGN_Agreement__c();
agmt.Name = 'Sample Agreement';
agmt.echosign_dev1__Recipient__c = '003O000000YcB0Q';// Contact field
agmt.echosign_dev1__Contract__c = '800O00000002sVx';// ContractID;
agmt.echosign_dev1__Merge_Mapping__c ='a0qO0000006npqT';//Echo Sign Merge Mapping
agmt.echosign_dev1__Process_Template__c ='a0kO0000003SdP2';// Echo Sign Data Mapping
agmt.echosign_dev1__RemindRecipient__c = 'Every Day, Until Signed';
agmt.echosign_dev1__SenderSigns__c = true;
agmt.echosign_dev1__Message__c = 'Please sign the attached Insertion Order';
agmt.echosign_dev1__SignatureType__c = 'e-Signature';
agmt.echosign_dev1__PasswordProtectSign__c = false;
agmt.echosign_dev1__SenderSigns__c = true;
agmt.echosign_dev1__PasswordProtectPDF__c = false;
agmt.echosign_dev1__SignatureOrder__c = 'Recipient signs, then I sign';
agmt.echosign_dev1__Status__c = 'Draft';
insert agmt;
System.debug(agmt);
attachment a1 = [select ID, parentId, Name, body, ContentType from Attachment where Id = '00PO0000002LCId'];
Attachment a = a1.clone();
a.parentId = agmt.id;
insert a;
Messaging.EmailFileAttachment attach = new Messaging.EmailFileAttachment();
attach.setContentType(a.contentType);
attach.setFileName(a.Name);
attach.setInline(false);
attach.Body = a.Body;
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
mail.setUseSignature(false);
mail.setToAddresses(new String[] {'test@gmail.com' });
mail.setSubject('Your Statement');
mail.setHtmlBody('Dear Customer,<br><br> Please find your statement attached in the email.');
// mail.setFileAttachments(new Messaging.EmailFileAttachment[] {a});
mail.setFileAttachments(new Messaging.EmailFileAttachment[] { attach });
// Send the email
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
}
