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

Is it Possible to sent Email with attachments in salesforce??
Hi,
Requirement I got is like there will be a mass delete on an object based on a condition and I have to export all the values to be deleted in an excel and have to sent it in a mail to an user
can this be implemented, if so plz help me...
Thanks in advance
Shank_dhel
If you are going to handle the mass deletion through apex then you can use apex email to send the email with the results from the deletion. There is a good deal of documentation in the technical library and some examples in cookbook regarding sending single email or email with templates.
You can process the results, create a VF email template, then create an excel sheet (using messaging:attachment) and then use that in the email you want to send out.
Here is some resources to get you started:
http://salesforcetrekbin.blogspot.dk/2010/05/visualforce-email-template-with.html
http://www.salesforce.com/us/developer/docs/pages/Content/pages_email_templates_attachments.htm
http://www.salesforce.com/us/developer/docs/pages/index_Left.htm#CSHID=pages_email_templates_attachments.htm|StartTopic=Content%2Fpages_email_templates_attachments.htm|SkinName=webhelp
good luck.
Hi
make a page to which to want send as attachment
<apex:page controller="ExcelsheetVfController" renderAs="pdf">
In this controller ExcelsheetVfController please write the logic for whatever value you want to send .
make anthoer page and controller from where you want to send mail ...In taht controller write all the logice for sending mail with attachment. Here is some you can follow .This is code tro send mail to user of contact object.Attachment is a perticular Quote detail .
public PageReference attachpdf()
{
Id quoteid = ApexPages.currentPage().getParameters().get('quoteid');
//cid----- means a contactId
Id cid = ApexPages.currentPage().getParameters().get('cid');
quote1 = [select id,name from Quote where id =:quoteid];
PageReference pdfPage = Page.pdfPage;
pdfPage.getParameters().put('id',quoteid);
Blob pdfBlob = pdfPage.getContent();
Attachment a = new Attachment(parentId = quote1.id, name=quote1.name + '.pdf', body = pdfBlob);
insert a;
PageReference nextpage = new PageReference('/apex/convertpdf?cid='+cid+'"eid='+quoteid);
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'PDF Attached Successfully'));
return nextpage;
}
public pageReference SendEmail()
{
Id quoteid = ApexPages.currentPage().getParameters().get('quoteid');
Id cid = ApexPages.currentPage().getParameters().get('cid');
for (String obj : selectedNames)
{
contact = [select Id,name,email from Contact where name =:obj];
System.debug('##########Mail###############'+contact.size());
for(Integer i=0; i < contact.size(); i++)
{
quote1 = [select id,name from Quote where id =:quoteid];
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
List<Messaging.Emailfileattachment> fileAttachments = new List<Messaging.Emailfileattachment>();
for (Attachment a : [select Name, Body, BodyLength from Attachment where ParentId = :quoteid])
{
Messaging.Emailfileattachment efa = new Messaging.Emailfileattachment();
efa.setFileName(a.Name);
efa.setBody(a.Body);
fileAttachments.add(efa);
}
email.setFileAttachments(fileAttachments);
email.setTargetObjectId(contact[i].Id);
email.setTemplateId(e1.id);
Messaging.sendEmail(new Messaging.SingleEmailMessage[] { email });
}
}
PageReference nextpage = new PageReference('/apex/convertpdf?quoteid='+quoteid+'&cid='+cid);
ApexPages.addMessage(new ApexPages.message(ApexPages.severity.INFO,'Email Sent Successfully'));
return nextpage;
}
I think It will help you..
Did this answer solve your problem ... If so please mark it solved
Thanks
asish
Salesforce is an excellent collaborative tool, but there can be some challenges when doing something unexpected such as sending large files as email attachments.
If you can’t use cloud storage online or an internal file storage system, you may need to share content through email. So MassMailer provides best email solution for customers across the globe to send mass emails on Salesforce CRM for email marketing and prospecting emails
MassMailer DOCS makes it easier to store and mass email large file attachments through Salesforce.
For this, you might need to visit and play with this app -
https://goo.gl/7UgBcn
For more details please click here
https://goo.gl/eVXBSG