[Seaside] WAEMailMessage, next step
Tony Fleig
tony.fleig at gmail.com
Fri Feb 25 10:12:57 UTC 2011
There may be some overlap here with
http://code.google.com/p/pharo/issues/detail?id=3509 (Multi-part MIME
messages for Pharo). I submitted these changes to support using multi-part
messages in TF-Login (http://www.squeaksource.com/TFLogin.html).
There's an example of creating and sending multi-part MIME content buried
here: http://www.tonyfleig.com/smallthoughts/tfloginguide/Tests/integrating
sendRegistrationConfirmationEmailTo: email confirmUrl: url timeoutMinutes: timo
"Compose and send email. Answer true on success, false on failure."
| textBody htmlBody emailOk appName |
appName := 'Login Test App'.
"Compose a pain text message."
textBody := (WriteStream on: String new)
<< 'This email is in response to your request to register at
'; << appName;
<< '.'; crlf;crlf;
<< 'Direct your browser to the following URL within ';<< timo asString;
<< ' minutes to confirm your registration.'; crlf;crlf;
<< ' '; << url; crlf;crlf;
<< 'If you did not attempt to register for a'; << appName;
<< ' account then this message was sent in error and should be
ignored.'.
"Compose a nice HTML message."
htmlBody := WAHtmlCanvas builder fullDocument: true; render: [ :html |
html div
style: 'font-size:11pt;';
with: [
html div
style: 'margin-bottom: 10px;';
with: 'This email is in response to your request
to register at ', appName, '.'.
html text: 'Click on the link below within ', timo asString,
' minutes to confirm your registration.'.
html div
style:
'margin-left:20pt;margin-top:10px;margin-bottom:10px;';
with: [
html anchor
url: url;
with: 'Confirm registration'].
html text: 'If the link above is unresponsive, copy
and paste the URL',
'below into your browser''s address field to
confirm your registration.'.
html div
style:
'margin-left:20pt;margin-top:10px;margin-bottom:10px;';
with: url.
html text: 'If you did not attempt to register for a', appName,
' account then this message was sent in error and
should be ignored.']].
"Send the message."
(emailOk := self
sendEmailTo: email
subject: appName, ' Registration - action required'
text: textBody html: htmlBody)
ifFalse: [ Transcript cr; show: url ].
^ emailOk
------------------------------
sendEmailTo: toAddress subject: subj text: textBody html: htmlBody
"Send multi-part MIME email message."
| sem mm|
mm := TLMailMessage empty.
mm addAlternativePart: textBody contents contentType: 'text/plain'.
mm addAlternativePart: htmlBody contents contentType: 'text/html'.
sem := mm
seasideMailMessageFrom: 'Registrar@' , self emailHost
to: toAddress
subject: subj.
[sem send] on: Exception do: [ :ex | ^ false ].
^ true
On Fri, Feb 25, 2011 at 8:32 AM, Philippe Marschall <
philippe.marschall at gmail.com> wrote:
> 2011/2/24 Diogenes Moreira <diogenes.moreira at gmail.com>:
> > Hi,
> > I'm thinking implement something like WAHtmlEmailBody...
> > the idea is generate a rich text email from a WAComponent...
> > In this direction I need solve 4 principal Issues
> > 1. Obtein "HTML" from the a component.. I can guess, i'll make something
> > like WAEMailCanvas..for render the email
>
> I don't know whether a WAComponent is really what you want. #call:,
> #answer:, #confirm: and friends all don't work.
>
> > 2. Obtein all resourses referenced by the HTML as Stream and attach it
> to
> > email message.
>
> Maybe only allowing #document: is easier.
>
> > 3. Replace the reourses's src attribute into html body for attachment
> > reference.
> > 4. Parse the HMTL Code to obtein plain text to add this alternativa to
> > email.
>
> Maybe it would be simpler to just write a second presenter for that.
> You'll probably want two new lines after a heading and one after a
> paragraph.
>
> Cheers
> Philippe
> _______________________________________________
> seaside mailing list
> seaside at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/cgi-bin/mailman/listinfo/seaside
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/seaside/attachments/20110225/1fb56785/attachment-0001.htm
More information about the seaside
mailing list