[seam-dev] Seam 3 Mail Feedback Follow-up

Dan Allen dan.j.allen at gmail.com
Mon Feb 28 17:23:49 EST 2011


On Sun, Feb 27, 2011 at 18:22, Cody Lerum <cody.lerum at gmail.com> wrote:

> 1. From Lincoln
>
> Utilizing an Interface for handling the different ways one could
> create an email template. -
> https://issues.jboss.org/browse/SEAMMAIL-19
>
>    This is Done.
>
> VelocityMailMessage vmm = velocityMailMessage.get();
>
>      vmm.from("seam at test.test", "Seam Framework")
>            .to(person)
>            .subject("HTML Message from Seam Mail - " +
> java.util.UUID.randomUUID().toString())
>            .bodyHtml(new VelocityClassPathTemplate("template.html.vm"))
>            .put("version", "Seam 3")
>            .importance(MessagePriority.HIGH)
>            vmm.send(session.get());
>

Excellent.


>
>   the contact fields also support a interface as well so one only
> need implement a getName and getAddress method on their User entity
> (for example) in order to pass it directly into an email -
>
> https://github.com/seam/mail/blob/6f70057cca7da712576c21f44bda80082ae1f0a1/examples/sendmail/src/main/java/org/jboss/seam/mail/example/Person.java


Good thinking! I like it.


>
> 5. From Dan via ALR reguarding ordering of the name and address in
> contact methods
>
>   I've reordered everything to aways takes Address first and then Name if
> any.
>
>   to("cody at test.com")
>   to("cody at test.com", "Cody")
>
>
> Thats what I have for now. The one question I have is do we just drop
> the ability to do
>
>   to("cody at test.com", "Cody")
>
> and require
>
>  to(new BaseEmailContact("cody at test.com", "Cody")
>
> this would allow a var args address only to/from/cc/bcc/replyTo
>
> Thus you could do:
>
> to("cody at test.com")
> to("cody at test.com", "dan at test.com")
>
> but anything with the acutal name would need to be done with
>
> to(new BaseEmailContact("cody at test.com", "Cody")
>

What about assuming that if there are exactly two arguments, and the second
argument is not an e-mail address, then you assume it's the name part for
the preceding. I know that's there's a hint of guesswork in there, but it
nicely caters to the prototype use case and likely will be appreciate to
"just work".

Example:

to("john.smith at acme.com", "joe.cool at peanuts.org", "john.doe at example.org") ->
3 recipients
to("john.smith at acme.com", "joe.cool at peanuts.org") -> 2 recipients
to("john.smith at acme.com", "John Smith") -> 1 recipients

You can use a regular expression to check for an e-mail address in the
second argument position, so long as you make it a configurable setting.

Keep in mind you can already do (if I'm not mistaken):

to("John Smith <john.smith at acme.com>", "Joe Cool <joe.cool at peanuts.org>")


> Of course if people are using existing objects it would be easier to
> just implement the EmailContact interface
>
> User user = new User("Cody", "cody at test.com", RoleType.ADMIN);
>

But you are right, there are plenty of other options. I think it's safe to
treat the two argument invocation as a special case.

-Dan

-- 
Dan Allen
Principal Software Engineer, Red Hat | Author of Seam in Action
Registered Linux User #231597

http://www.google.com/profiles/dan.j.allen#about
http://mojavelinux.com
http://mojavelinux.com/seaminaction
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/seam-dev/attachments/20110228/b6b37eb8/attachment.html 


More information about the seam-dev mailing list