You need to sign in to do that
Don't have an account?
fileattachments
I have a visualforce pdf as an attachment already. I need to add another static file to be added as an attachment. Should it be in the documents section or the static resource section?
PageReference opppdf = Page.opppdf; opppdf.getParameters().put('id',opp1.id); Blob pdf = opppdf.getContent();
Messaging.EmailFileAttachment mailAttachment; mailAttachment = new Messaging.EmailFileAttachment(); mailAttachment.setFileName('test1.pdf'); mailAttachment.setBody(pdf);
for the second attachment which is static file
Messaging.EmailFileAttachment mailAttachment1; mailAttachment1 = new Messaging.EmailFileAttachment(); mailAttachment1.setFileName('test2.pdf'); mailAttachment.setBody(pdf1); mail.setFileAttachments(new Messaging.EmailFileAttachment[] { mailAttachment, mailAttachment1 })
how do i access the content of the file and attach it to the email?
- Sand
If you put it as a static resource, you can access it as $Resource.<yourresourcename>.
But, if you are uploading these docs to your org to send as an email attachment, why don't you use the "Content Delivery" feature that is introduced in Spring '09. You simply send a link to the content (after you upload it to your org) as an email and you have complete control as to whether the recipient can view/download etc that content etc.,. No more huge file attachments.
Take a look at this feature. Ofcourse, this feature needs to be enabled by your Salesforce support rep, though.
How can I access the static resource within a controller or apex code? I can use it as merge field within Visualforce markup, but not sure how to access from within apex.
Content delivery is something worth considering, but right now, I just need to get this one part to finish what I've been working on.
Thanks
Sand
As of Sprint '09, there is no direct way to get the URL or Resource content from APEX. But here is a work around that is described at the following blog entry. Scroll towards the bottom to see a couple of APEX functions.
Getting Resource URLs from APEX
Good luck.
That seems odd to me that there is no way to attach a file as an attachment using the sendemail api.
Just to give more context to my issue. I'm making a callout from a visualforce controller to an apex class which uses the sendemail api to send out emails. I'm passing relevant information to it along with blob of the first attachment (which is a visualforce page being rendered as a pdf). If I could do the same for the second attachment (which is a static pdf file)in any way,either in the controller code or in the apex email class.
I tried that work around. Didnt exactly work for me. May have to give it another shot
Compile Error: unexpected char: 0xȹ8 at line 60 column 100