[erlang-questions] esmtp: send PDF as an attachment
Amancio Díaz Suárez
adiaz@REDACTED
Tue May 24 18:52:48 CEST 2011
Hi Mickael,
I got something like this and works fine.
MimeContent = #mime_part{data = NewContent,
type = inline,
encoding = {"7bit","text/html","utf-8"},
name = "txt.html"},
{ok, PngContent0} = file:read_file(?MAIL_PNG_LOGO),
PngContent1 = base64:encode(PngContent0),
PngContent = erlang:binary_to_list(PngContent1),
Atach2 = #mime_part{data = PngContent,
type = attachment,
encoding= {"base64", "image/png",
"iso-8859-1"},
name= FileNameLogo},
Msg0 = #mime_msg{} = esmtp_mime:msg(SmtpTo, SmtpFrom, SmtpSubject),
Msg = Msg0#mime_msg{parts = [MimeContent, Atach2]},
esmtp:send(Msg).
change the MIME type, use "application/pdf" instead of "image/png".
Amancio.
El mar, 24-05-2011 a las 18:16 +0200, Zabrane Mickael escribió:
> Hi guys,
>
>
> I'd like to use "esmtp" to send emails with attachment:
> https://github.com/archaelus/esmtp
>
>
> Unfortunately, the doc is a bit sparse.
>
>
> Could someone help on how for email send an email with a PDF
> (eg. /tmp/foo.pdf) as an attachment?
> Thanks !
>
> Regards,
> Zabrane
>
>
More information about the erlang-questions
mailing list