NSData pdfAttachment = pdfReport.content(); On 07/12/2011, at 11:40 PM, Raymond NANEON wrote:
> Hi,
>
> Thanks for all advices and the sent mail methods but sorry I think I was not
> clear in my question. My problem is get the file inside the generated
> component by this method :
>
> public WOActionResults downloadAsPDF() {
>
> NSMutableDictionary<String, Object> configuration = new
> NSMutableDictionary<String, Object>();
> WOContext context = (WOContext) context().clone();
>
> MyPDFPage pdfPage = (MyPDFPage)
> WOApplication.application().pageWithName(MyPDFPage.class.getName(), context);
> pdfPage.setMyObject(myObject());
>
> String baseFileName = someString();
> String filename = pdfDocumentPrefix() + baseFileName + ".pdf";
> configuration.takeValueForKey(filename, "filename");
>
> WOResponse pdfReport = ERPDFUtilities.pageAsPdf(pdfPage,
> configuration).generateResponse();
>
> return pdfReport;
> }
> Envoyé depuis iCloud
>
> Le 07 déc 2011 à 04:47, "pavan.jayam" <[email protected]> a
> écrit :
>
>> Hi,
>>
>> I used mailapi.jar to send a mail from java program.
>>
>> Attached a pdf to the mail and sent to multiple users.
>>
>> Here is the code:
>> ------------------------------------------------------------------------------------------------
>> try{
>> File file=new File("report.pdf");
>> FileOutputStream fos = new FileOutputStream(file);
>> fos.write(data);
>>
>> // data is pdf byte array fo the pdf file//
>>
>> Multipart mp = new MimeMultipart();
>> MimeBodyPart htmlPart = new MimeBodyPart();
>> htmlPart.setContent("This is a test mail with PDF
>> attachment<br><br><br>", "Text/HTML");
>> mp.addBodyPart(htmlPart);
>>
>> MimeBodyPart mimeBodyPart = new MimeBodyPart();
>> DataSource dataSource = new FileDataSource(file)
>> {
>> public String getContentType()
>> {
>> return "application/pdf";
>> }
>> };
>>
>> mimeBodyPart.setDataHandler(new DataHandler(dataSource));
>> mimeBodyPart.setFileName(file.getName());
>> mimeBodyPart.setHeader("Content-Transfer-Encoding", "base64");
>> mimeBodyPart.setDisposition(Part.ATTACHMENT);
>>
>> mp.addBodyPart(mimeBodyPart);
>> msg.setContent(mp);
>> Transport.send(msg);
>> }
>> catch (Exception e) {
>> System.out.println("Error Message: "+e);
>> e.printStackTrace();
>> }
>>
>> ------------------------------------------------------------------------------------------------
>> Regrads,
>> PJ.
>>
>> Paul Yu wrote:
>>>
>>> Raymond
>>>
>>> I have not done this in a complete loop, so you will need to experiment.
>>>
>>> But the basic process would be something like this.
>>>
>>> 1) Do the PDF generation, but return the response into an NSData
>>> 2) Then follow the pattern in Pascal's link to put the NSData as content
>>> on the
>>>
>>> message.addAttachment(new ERMailDataAttachment("myattachment.pdf", null,
>>> content));
>>>
>>> Paul
>>> On Dec 7, 2011, at 7:11 AM, Pascal Robert wrote:
>>>
>>>
>>>> Have a look at ERJavaMail, you can send attachments with it.
>>>>
>>>> http://wiki.objectstyle.org/confluence/display/WO/Project+WONDER-Frameworks-ERJavaMail
>>>>
>>>>
>>>>> Hi Paul,
>>>>>
>>>>> I would like to get the pdf file and sent it directly by mail with a
>>>>> method. How can I get the the file in the pdfReport component?
>>>>>
>>>>> Thanks for your help.
>>>>>
>>>>> Envoyé depuis iCloud
>>>>>
>>>>> Le 17 nov 2011 à 07:06, Paul Yu <[email protected]> a écrit :
>>>>>
>>> _______________________________________________
>>> Do not post admin requests to the list. They will be ignored.
>>> Webobjects-dev mailing list ([email protected])
>>> Help/Unsubscribe/Update your Subscription:
>>> http://lists.apple.com/mailman/options/webobjects-dev/pavan.jayam%40prithvisolutions.com
>>>
>>> This email sent to [email protected]
>>>
>>>
>>>
>>>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Webobjects-dev mailing list ([email protected])
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/webobjects-dev/qdolan%40gmail.com
>
> This email sent to [email protected]
smime.p7s
Description: S/MIME cryptographic signature
_______________________________________________ Do not post admin requests to the list. They will be ignored. Webobjects-dev mailing list ([email protected]) Help/Unsubscribe/Update your Subscription: http://lists.apple.com/mailman/options/webobjects-dev/archive%40mail-archive.com This email sent to [email protected]
