You need to sign in to do that
Don't have an account?
rmranjith8881.3927046400771116E12
Sending two attachments by using standard email UI!!!
Hi EveryOne,
The user request is that when a Custom button(Send Email) is clicked on the oportunity screen it should open a standard email UI and select the email template associated to the product for the template in that body and two attachments - attachment1 and attachment2 .
I am able to achieve all the functionality but we can add only one attachment. when we call the url to call that standard email page, we can only add one &docid = .
I am Passing this URL:
emailURL = '/_ui/core/email/author/EmailAuthor?p2_lkid=' + opp.Account.id + '&p3_lkid=' + opp.id +
'&template_id='+getTemplateId(opp.Product__r.Name) + '&doc_id='+getCreatedDocId();
With this I am able to do the above functionality of sending email with one attachment.
How do I send 2 attachments?
Thanks In advance.........
I am sending my code below.
The user request is that when a Custom button(Send Email) is clicked on the oportunity screen it should open a standard email UI and select the email template associated to the product for the template in that body and two attachments - attachment1 and attachment2 .
I am able to achieve all the functionality but we can add only one attachment. when we call the url to call that standard email page, we can only add one &docid = .
I am Passing this URL:
emailURL = '/_ui/core/email/author/EmailAuthor?p2_lkid=' + opp.Account.id + '&p3_lkid=' + opp.id +
'&template_id='+getTemplateId(opp.Product__r.Name) + '&doc_id='+getCreatedDocId();
With this I am able to do the above functionality of sending email with one attachment.
How do I send 2 attachments?
Thanks In advance.........
I am sending my code below.
//Send the CCL Document to the potential when we cliclk the Send CCL Button. public class CCLSendEmail { public Account acc; public Opportunity opp; public CCL_Documents__c cclDocs;//Custom settings Product_EmailTemplates__c template;//Custom settings public CCLSendEmail(ApexPages.StandardController controller){ opp = [Select Id, Account.id, Product__r.Name, Account.Name,StageName from Opportunity where Id = :ApexPages.currentPage().getParameters().get('id')]; } public PageReference pdfEmail(){ try{ if(opp.StageName.equals('CCL Sent')){ String emailURL; emailURL = '/_ui/core/email/author/EmailAuthor?p2_lkid=' + opp.Account.id + '&p3_lkid=' + opp.id + '&template_id='+getTemplateId(opp.Product__r.Name) + '&doc_id='+getCreatedDocId(); PageReference cclPage = new PageReference(emailURL); cclPage.setRedirect(true); return cclPage; } else{ ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.WARNING, 'Email Template is not there for this perticular Product'); return null; } }catch(Exception e){ ApexPages.Message myMsg = new ApexPages.Message(ApexPages.Severity.WARNING, e.getMessage()); ApexPages.addMessage(myMsg); return null; } } public String getCreatedDocId(){ Blob content; cclDocs = CCL_Documents__c.getInstance('VNP CCL Documents'); PageReference pr = Page.CCLPdf; pr.setRedirect(true); pr = Page.CCLPdf; pr.setRedirect(true); pr.getParameters().put('id', opp.id); if(!Test.isRunningTest()){ content = pr.getContentAsPDF(); } Document doc = new Document(Name = opp.Account.Name+'.PDF', Body = content, FolderId = cclDocs.Document_Id__c); Database.SaveResult insertResult = Database.Insert(doc, true); return doc.Id; } public String getTemplateId(String prodName){ template = [Select Name, Email_Template_Id__c from Product_EmailTemplates__c where Name = : prodName]; return template.Email_Template_Id__c; } }
We can't send the Multiple Attachments by overriding the Send an Email Button(Which i tried above).
So, I tried differently and I posted below for referenced to others.
I was able to send more than one email attachment by writing below Extensions and Visulforce page.
Extensions:
Visualforce Page:
Don't forget to Create a Button on Opportunity.
I hope, it helps a lot.
Thanks
Ranjith
All Answers
Create onemore document, return should be Id List, change the string return to Id list or string list
Shaijan
We can't send the Multiple Attachments by overriding the Send an Email Button(Which i tried above).
So, I tried differently and I posted below for referenced to others.
I was able to send more than one email attachment by writing below Extensions and Visulforce page.
Extensions:
Visualforce Page:
Don't forget to Create a Button on Opportunity.
I hope, it helps a lot.
Thanks
Ranjith