You need to sign in to do that
Don't have an account?
Email using visualforce and apex
Hi
I really have no clue regarding email using visualforce and apex.Can anyone help me on this...
I want to send some data from my previous page as well as the current page data as an email.
Here i am refering to my custom object and its custom field data.
Please help me on how to send the VF page as a part of email ,only on click of a button say 'Send Mail'.Also i want the user to
type the email address in the box provided in VF page before he clicks the button.
What is email template?Is it really required to send email...If so,can i display my VF page as a template so that data to be sent
is entered in body section directly?
You can create a visalforce email template to send a output to any user.
http://wiki.developerforce.com/page/VisualForceEmailTemplates_sample
http://www.forcetree.com/2009/08/visualforce-email-template.html
To send an email to user you can use SingleEmailMessage class.
http://www.forcetree.com/2009/07/sending-email-from-your-apex-class.html
Hi,
You can send an email in salesforce through Messaging.singleEmailMessage class,In apex you can EmailFileAttachment methods to attach the binary and text files bind with the email. The EmailFileAttachment object is used in the SingleEmailMessage object to specify attachments passed in as part of the request, as opposed to existing documents in Salesforce.
Messaging.EmailFileAttachment efa = new Messaging.EmailFileAttachment();
efa.setFileName('attachment.pdf');
efa.setBody(hexcode);
Messaging.SingleEmailMessage email = new Messaging.SingleEmailMessage();
String[] toAddresses = new string[]{'dummy@yahoo.com'}
email.setSubject( subject );
email.setToAddresses(toAddresses);
email.setPlainTextBody(Msg);
email.setFileAttachments(new Messaging.EmailFileAttachment[] {efa});
// Sends the email
Messaging.SendEmailResult [] r =
Messaging.sendEmail(new Messaging.SingleEmailMessage[] {email});
Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.
hi
how do i modify the toaddress string ?
String[] toAddresses = new string[]{'dummy@yahoo.com'}
i want the user to enter the email id into a input text field (in VF page) and this should be considered as toaddress email id.
or can it be done using the email id i.e. stored in database of the record.How do i fetch the email id from database and use this as toaddress email id.
Create a input text field in the VF page and define binding variable which will hold the email id entered. Define setter and getter for this variable and add to the toAddress list..
For more info on VF pages, see Visaulforce Developer Guide.
Thanks that worked...
Thanks a lot everyone... :)