+ Start a Discussion
Frederik Witte 19Frederik Witte 19 

Complex SalesForce process - need help on where to get started

Hey guys, 

I have to work on the following project: 

An external button calls a REST Webservice and sends an ID. This ID is the trail to the user which called the button. Now I need to generate a .pdf with the user information. This .pdf then needs to be send to three different e-mail addresses, of which one has a different body. All of this needs to be done programmatically, so that the user only presses a button, and the rest is done automatically.

 

I found a huge documentation about REST Webservice, so I don't need a start here. But I can't find a documentation on how to generate a .pdf all by code and send this via email. All I could find is .pdf in combination with a visualforce page. Does someone have a nice tutorial on generating a .pdf by code only and sending it via mail? 

Thanks in advance!

Best Answer chosen by Frederik Witte 19
Balaji Chowdary GarapatiBalaji Chowdary Garapati
@Frederik Witte
Take a look at below link,

http://www.salesforce.com/docs/developer/pages/Content/pages_email_sending_attachments.htm


All you need is a visualforce page rendered as pdf which has the visual content, a class which gets the pdf content creates and attachement and uses singleemailmessage class to send out the email.

Hope it helps.,

Thanks,
Balaji

All Answers

Balaji Chowdary GarapatiBalaji Chowdary Garapati
@Frederik Witte
Take a look at below link,

http://www.salesforce.com/docs/developer/pages/Content/pages_email_sending_attachments.htm


All you need is a visualforce page rendered as pdf which has the visual content, a class which gets the pdf content creates and attachement and uses singleemailmessage class to send out the email.

Hope it helps.,

Thanks,
Balaji
This was selected as the best answer
Frederik Witte 19Frederik Witte 19
One question about that. As there are different users clicking the button, the .pdf needs to be non static. So I need to fill out different information. When I create a visualforce page, can I then create different .pdfs and send them and all of this programmatically?
Balaji Chowdary GarapatiBalaji Chowdary Garapati
I think i quite didnt get your question!?

Are you asking, instead of having the same content on page every time, it should be changed based on input or some params? The answer is yes, it is just a visual force page rendered as pdf, so you can control what to show up or what to hide on page at the time of generation using a controller for the pdf page. The example is just to demo how it works, you can have a controller written to that page which controlls the logic and content of page.

Did it clarify your quesiton?

Regards,
balaji
Frederik Witte 19Frederik Witte 19

I hope we are one the same level. The page where the button is being called is not a visualforce page. This button just calls a webservice. 

 

Everything after that button is being clicked, should happen programmatically, so that the user doesn't have to do anything and there are just 3 mails send with the generated .pdf attachment. 

Is this possible with what you suggested?

Thank you really much for your time!

Balaji Chowdary GarapatiBalaji Chowdary Garapati
Yes it can be done!  You can utilise the piece of code from above example in the webservice class which is being invoked by the button, it just sends the email out with the pdf you are willing to attach!

Cheers,

 Just go for it! if you are stuck with some thing, reply to same thread, I will definitely try to help you out!

Thanks,
balaji
Frederik Witte 19Frederik Witte 19
Awesome! Thank you really, really much. I will definetely update when I achieve something and post the code here :-)