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

InboundEmailHandler and PageReference.getContent()
I created an email service that creates an attachment to a custom object. That attachment is based on the content of a Visualforce page. A PageReference gets created and then I take the content of that page and use it for the attachment body. Code is something like this:
PageReference pdfPage = Page.CustomerQuoteDisplay;
pdfPage.getParameters().put('id', quoteId);
Attachment attachment = new Attachment();
attachment.ParentId = quoteId;
attachment.name = 'QuoteSent';
attachment.body = pdfPage.getContent();
insert attachment;
This all works fine when similar code is initiated from a page action. However, in my InboundEmailHandler, getContent() returns this:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html><head>
<meta HTTP-EQUIV="PRAGMA" CONTENT="NO-CACHE">
<script>if (window.location.replace){ window.location.replace('https://login.salesforce.com/?ec=302&startURL=%2Fvisualforce%2Fsession%3Furl%3Dhttps%253A%252F%252Fc.na6.visual.force.com%252Fapex%252Fcustomerquotedisplay%253Fid%253Da0E80000003MySFEA0%2526inline%253D1%2526core.apexpages.devmode.url%253D1');
} else {
;window.location.href ='https://login.salesforce.com/?ec=302&startURL=%2Fvisualforce%2Fsession%3Furl%3Dhttps%253A%252F%252Fc.na6.visual.force.com%252Fapex%252Fcustomerquotedisplay%253Fid%253Da0E80000003MySFEA0%2526inline%253D1%2526core.apexpages.devmode.url%253D1';}
</script>
</head></html>
<!--............................................................................................................................................................................................................................................................................................................................................................................................................
-->
Basically, it's redirecting to the login page. If I pasted the url into a browser and logged in, it would take me to the page I want. I read an old post (01/09) that said getContent() was not supported in @future methods. Does the same apply to email handlers? Is the handler executed in some non-logged in context?
Thanks,
Rob