1 respuesta
You could write an email template that you could then send off from the "save" method in your visualforce page controller?You must have a custom controller to handle the saving of the two objects? So in that method use some of the SimpleEmailMessage stuff to fire out an e-mail:
of course, thinking about it - I hope you have a relationship between your two objects so you can reference their two fields on the same template...Regarding doing that, once you have setup a "Visualforce" email template - you should be able to copy and paste your page into it, jiggle the inputs into outputs and resuse that code. That is suboptimal I admit, because you'd have to maintain both files, but I don't think you can just reuse the input form as an output for e-mail.You might be able to use "getContentAs" to attach the original Visualforce page to an e-mail as a PDF? Might that work? Turning the inputs straight into outputs (or leaving them visually as inputs, but in a PDF it would just look like a form).Is any of that any use?EmailTemplate template = [SELECT Id FROM EmailTemplate WHERE name = 'MyTemplate'];
List<Messaging.SingleEmailMessage> msgs = new List<Messaging.SingleEmailMessage>();
Messaging.SingleEmailMessage msg = new Messaging.SingleEmailMessage();
msg.setTemplateID(template.Id);
msg.setToAddress(/* work out who you want to get it */);
msg.setWhatId(custom_object.Id);
msgs.add(msg);
Messaging.sendEmail(msgs,false);