Copy link to clipboard
Copied
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 });
}
}
Hi,
If you want to use the EchoSign API directly to send, then you will need to invoke the sendDocumentInteractive API, constructing the SOAP request. Here is the documentation - https://corporate.echosign.com/public/docs/EchoSignDocumentService19?#sendDocumentInteractive
But an easier way is to use the wrapper we provide to send the agreement, make sure you have v15 of our app installed, the latest from the AppExchange, then from your apex code invoke the global echosign_dev1.EchoSignApiService c
...Copy link to clipboard
Copied
Hi,
If you want to use the EchoSign API directly to send, then you will need to invoke the sendDocumentInteractive API, constructing the SOAP request. Here is the documentation - https://corporate.echosign.com/public/docs/EchoSignDocumentService19?#sendDocumentInteractive
But an easier way is to use the wrapper we provide to send the agreement, make sure you have v15 of our app installed, the latest from the AppExchange, then from your apex code invoke the global echosign_dev1.EchoSignApiService class sendDocument method, passing in the Id of the agreement record which you have created.
Thanks
Copy link to clipboard
Copied
To send Agreements using Apex, I have successfully used a blend of Templates and Apex.
See below for the example.
Template Id: references the template which has the Master Object, Agreements, Merge Mappings already setup.
Lead Id: Id from the Lead record referenced in the template.
// Start by generating an agreement Id by loading the template with masterId.