Attachment in mail

43 views
Skip to first unread message

Bat

unread,
Dec 12, 2011, 12:12:31 PM12/12/11
to Google App Engine
Hi,

One of my servlet creates CSV content in a String variable.

I'd like to send this CSV like an attachment file but everybody knows
the limitations of GAE : it's impossible to create a file. So, I
decided to find an another solution.

Mine is to attach the CSV string like that :
String csv = "";
Message msg = new MimeMessage(session);
msg.setDataHandler(new DataHandler(new
ByteArrayDataSource(csv.getBytes(),"text/csv")));
msg.setFileName("data.csv");

I receive the mail but without attachment. The CSV string is
integrated into the body part of the mail.

How to attach this CSV string like a CSV file into the mail?

Thanks

Timofey Koolin

unread,
Dec 12, 2011, 12:19:40 PM12/12/11
to google-a...@googlegroups.com
message = mail.EmailMessage()message.sender = sendermessage.subject =
subjectmessage.to = receivermessage.body = textmessage.attachments = [
                ("filename.csv", csv.getBytes())            ]
2011/12/12 Bat <batistutag...@gmail.com>:
> --
> You received this message because you are subscribed to the Google Groups "Google App Engine" group.
> To post to this group, send email to google-a...@googlegroups.com.
> To unsubscribe from this group, send email to google-appengi...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-appengine?hl=en.
>

--
Blog: www.rekby.ru

Timofey Koolin

unread,
Dec 12, 2011, 12:20:39 PM12/12/11
to google-a...@googlegroups.com
message = mail.EmailMessage()


message.sender = sender

message.subject =subjectmessage.to = receiver

message.body = text

message.attachments = [
                ("filename.csv", csv.getBytes())           
]


2011/12/12 Timofey Koolin <tim...@koolin.ru>:
--
Blog: www.rekby.ru

Batistuta Gabriel

unread,
Dec 12, 2011, 12:26:08 PM12/12/11
to google-a...@googlegroups.com
Thanks.

What's the type of "message" in your answer.

Actually, I use this code :
Message msg = new MimeMessage(session);
msg.setDataHandler(new DataHandler(new ByteArrayDataSource(csv.getBytes(),"text/csv")));
msg.setFileName("data.csv");



msg.setFrom(new InternetAddress("***", "****"));
msg.addRecipient(Message.RecipientType.TOnew InternetAddress("****", "info"));
msg.setSubject("Export");

Transport.send(msg);


Thanks

Le 12-déc.-11 à 18:20, Timofey Koolin a écrit :

Timofey Koolin

unread,
Dec 12, 2011, 12:53:40 PM12/12/11
to google-a...@googlegroups.com
from google.appengine.api import mail

message = mail.EmailMessage()


2011/12/12 Batistuta Gabriel <batistutag...@gmail.com>



--
Blog: www.rekby.ru

voscausa

unread,
Dec 12, 2011, 1:04:53 PM12/12/11
to google-a...@googlegroups.com
You can use the blobstore to save / create files like CSV, PDF's and access these files with the file interface.

Batistuta Gabriel

unread,
Dec 12, 2011, 1:36:33 PM12/12/11
to google-a...@googlegroups.com
Many thanks..It works

Le 12-déc.-11 à 18:53, Timofey Koolin a écrit :
Reply all
Reply to author
Forward
0 new messages