On Sun, Feb 27, 2011 at 18:22, Cody Lerum <cody.lerum@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@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@test.com")
  to("cody@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@test.com", "Cody")

and require

 to(new BaseEmailContact("cody@test.com", "Cody")

this would allow a var args address only to/from/cc/bcc/replyTo

Thus you could do:

to("cody@test.com")
to("cody@test.com", "dan@test.com")

but anything with the acutal name would need to be done with

to(new BaseEmailContact("cody@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@acme.com", "joe.cool@peanuts.org", "john.doe@example.org") -> 3 recipients
to("john.smith@acme.com", "joe.cool@peanuts.org") -> 2 recipients
to("john.smith@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@acme.com>", "Joe Cool <joe.cool@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@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