You need to sign in to do that
Don't have an account?

Is there any way to send an Email with Attachment??
Hi All,
I want to send an email with the selected Attachment from Notes and Attachment related list....
i.e. i have some file inside Notes and Attachment related list.. and i want to select one file out of them.. and want to email that with some template.. please let me kow how can i do that...
Thanks
I think you need to move with custom Visual force page approach,
And need to implement custom functionality to pick Email template and Attachements, As by using Salesforce Standard
salesforce.com/_ui/core/email/author/EmailAuthor functionality will allow you to pick attachment only from documents,
Not from related list attachments.
Please redefine your requirement in more detail way, so I can suggest accordingly
Cheers,
Bala
Hi Bala,
My requirement is as follows:
I need a button on the Custom Object Page layout, to send an email in a specified Template with an Attachment. Before sending the mail I need to select one attachment from all attachments that are available inside Notes and Attachment Related list.
Now, in order to achieve this
(1) i have create a Checkbox on the page
(2) Onclick of a detail page button.. i am running the javascript code to make the checkbox as true i.e. checked
(3) Create a workflow, when the checkbox is True i.e. checked and email alert will fire with the selected Email Template.
Now, i am able to send an email with a template but.. i am not able to understand how can i select and relate attachment with it.
Or,
i will have to follow another approach to fulfill the needs...
Please let me know the way of achieving it...
Also, please get the following details:
Custom Object Name is: opportunity_proposals__c
Custom field that contain the email id: SMEs_Email__c
Javascript code i have written to update the checkbox value:
{!requireScript("/soap/ajax/20.0/connection.js")}
{!requireScript("/soap/ajax/20.0/apex.js")}
var temp= new sforce.SObject("opportunity_proposals__c");
temp.Id ="{!opportunity_proposals__c.Id}";
temp.EMAIL_TO_SME__c = 'True';
try
{
sforce.connection.update([temp]);
}
catch(e)
{
alert(e)
}
after that a simple workflow with Email alert action... :)
this is all what i have...
Hey,
If you want to select attachment from related list of notes and attachment , you need to go for Visualforce page ,
Query related attachment and attach to email.
** here we can not use standard sendEmail page , there we can select attachment only from documents
Hope It will help you.
Cheers,
Bala
Hi Bala,
Based on your suggestion... i have tried creating the visualforce page and an apex class... But how can i select one attachment from the visualforce page and send it as an attachment inside mail??? is getting difficult
The Apex class is:
public class testmail
{
ApexPages.StandardController controller;
public opportunity_proposals__c q
{
get;set;
}
String op = ApexPages.currentPage().getParameters().get('id');
public Id oppr
{ get;set; }
public testmail(ApexPages.StandardController ctrl)
{
oppr = ctrl.getRecord().Id;
}
public PageReference emailAtt()
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[]{'SMaster@gmail.com'};
mail.setToAddresses(toAddresses);
mail.setReplyTo('SMaster@gmail.com');
mail.setSenderDisplayName('CRM Support');
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setTargetObjectId('005Q0000000FR7f');
mail.setTemplateId('00XQ0000000QULj');
mail.saveAsActivity = false;
//Set email file attachments
List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
for (Attachment a : [select Id, Name, Body, BodyLength from Attachment where ParentId = :oppr])
{
// Add to attachment file list
Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
efa.setFileName(a.Name);
efa.setBody(a.Body);
fileAttachments.add(efa);
}
mail.setFileAttachments(fileAttachments);
//Send email
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
return null;
}
}
and the Visualforce page is:
<apex:page standardController="opportunity_proposals__c" extensions="testmail">
<apex:form >
<apex:pageBlock title="Attachments">
<apex:pageBlockButtons >
<apex:commandButton value="Send" action="{!emailAtt}"/>
</apex:pageBlockButtons>
<apex:pageBlockTable value="{!opportunity_proposals__c.Attachments}" var="Att">
<apex:column headerValue="Select">
<apex:inputCheckbox value="{!opportunity_proposals__c.for_sendemailwithattachment__c}"/>
</apex:column>
<apex:column value="{!Att.createddate}"/>
<apex:column value="{!Att.name}"/>
<apex:column value="{!Att.description}"/>
</apex:pageBlockTable>
</apex:pageBlock>
</apex:form>
</apex:page>
in addition to my previous message...
I am able to send all attachment.. sucessfully.. but not the selected one...
I didnt get this
" I am able to send all attachment.. sucessfully.. but not the selected one... "
.
.
.
also how you are selecting the attachment from VF page ?
Thanks,
Bala
Hi Bala,
The scenario is something like:
I have created an apex class, in which i have created a method to to send an email with attachment .
then i created another visualforce page, where i am showing all the Notes and Attachment from the related list.... and a commandbutton on which clicking an email gets fired with all attachments... lets say if i have 3 files inside the attachment.. all will go out as an attachment with in one mail....
that is working till now...
Now... i need to select an attachment before sending the mail.... and only the selected attachment should go out with in a mail as attachment....
please let me now if i am unable to explain...
Hi Bala,
I was trying to implement this (i.e. sent the selected file as attachment within the email) using the wrapper class.. but unable to do so.. here is the code i am using...
or, please suggest the suitable solution to resolve this issue.....
Apex class:
public class Checkbox_Class
{
public Id oppr { get;set; }
public Checkbox_Class(ApexPages.StandardController ctrl)
{
oppr = ctrl.getRecord().Id;
}
List<Attachmentwrapper> AttachmentList = new List<Attachmentwrapper>();
List<Attachment> selectedAttachments = new List<Attachment>();
public List<Attachmentwrapper> getAttachments()
{
for (Attachment a : [select Id, Name, Body, BodyLength from Attachment where ParentId = :oppr])
{
AttachmentList.add(new Attachmentwrapper(a));
return AttachmentList;
}
}
public PageReference getSelected()
{
Messaging.SingleEmailMessage mail = new Messaging.SingleEmailMessage();
String[] toAddresses = new String[]{'ashish.garg@headstrong.com'};
mail.setToAddresses(toAddresses);
mail.setReplyTo('ashish.garg@headstrong.com');
mail.setSenderDisplayName('CRM Support');
mail.setBccSender(false);
mail.setUseSignature(false);
mail.setTargetObjectId('005Q0000000FR7f');
mail.setTemplateId('00XQ0000000QULj');
mail.saveAsActivity = false;
//selectedAttachments.clear();
for(Attachmentwrapper accwrapper : AttachmentList)
{
if(accwrapper.selected == true)
{
selectedAttachments.add(accwrapper.acc);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { mail });
}
else
{
return null;
}
}
public List<Attachment> GetSelectedAttachments()
{
if(selectedAttachments.size()>0)
return selectedAttachments;
else
return null;
}
public class Attachmentwrapper
{
public Attachment acc{get; set;}
public Boolean selected {get; set;}
public Attachmentwrapper(Attachment a)
{
acc = a;
selected = false;
}
}
}
yap.... I looked into it,
sorry for delayed response give me some time, will post updated controller later on..
thanks,
Bala
Hi Bala,
i expect you would have looked into the problem... please suggest...
Hi sMaster,
I know this post is very old but am trying to implement something similar to this.Did you succeed & if so can you kindly post your final controller?
Thanks in advance.
My users would like to send an email from a custom object, but they would like to attach an attachment from the list of attachments on the custom object.
Thanks!
Please share if anyone found
If you want to send an Email with Attachment a native salesforce app MassMailer DOCS is perfect for you.
MassMailer DOCS let’s you send mass email attachments to your leads or contacts while securely storing your files with Rackspace Cloud Files.
You can try this app by installing from appexchange -Massmailer Docs
You can learn more details about the product on this website - docs.massmailer.io