|
From: Matt S. <sga...@us...> - 2005-02-17 00:14:14
|
I've been trying to post this all day, but I think the issue was it didn't like my ZIP attachment. I agree with David that a higher-level abstraction over the JavaMail API might be appropriate. I think the existing MimeMessageHelper etc. is rooughly equivalent to the JdbcTemplate, and we're missing the equivalent higher-level abstractions similar to MappingSqlQuery, etc. I actually wrote a higher-level abstraction layer like this over Spring's API. The source is available at the URL below. The company I work for is a strong supporter of open source, and would be happy to donate this code to Spring. I personally would also be happy to "Spring-ify" the code to add comments, licensing, etc. Of course a committer could then go through and clean it up further. http://www.crystalcognition.com/sgarlatm/email.zip Matt Juergen Hoeller wrote: > Thanks for the suggestion, David. Such a common interface for mail messages > is a good idea. > > However, the setters in the interface shouldn't throw > javax.mail.MessagingException, which is a checked JavaMail exception. > Consequently, I've redesigned the setters to throw MailParseException, and > implemented a MimeMailMessage adapter that translates the calls into > MimeMessageHelper calls (properly converting exceptions). > > Message population code can now interact with either a SimpleMailMessage or > a MimeMailMessage through the common MailMessage interface. > > Juergen > > > -----Original Message----- > From: spr...@li... > [mailto:spr...@li...]On Behalf > Of David Bowers > Sent: Wednesday, February 16, 2005 4:12 PM > To: spr...@li... > Subject: Re: [Springframework-developer] common super-interface in mail > functionality > > > Thanks for the response. > > I think the best way to explain is to just send the interface I have > in mind, so it is attached. This would be implemented by > SimpleMailMessage and MimeMessageHelper. Both classes already have > all these methods, so no further change would be needed. > > I have an application that sends e-mail, sometimes plain text, and > sometimes html. I set up the template subject, sender, and text of > the e-mail as a non-singleton spring bean, and then add my more > specific recipient list in code. I would like to be able to access > the SimpleMailMessage and the MimeMessageHelper through a common > interface, especially for a method like setTo(String). I guess I > could send both html and text through the MimeMessageHelper, but it > seemed like a common interface wouldn't hurt anything. > > /David Bowers > > > On Tue, 18 Jan 2005 20:02:13 +0100, Alef Arendsen <al...@jt...> wrote: > >>What do you intend to do? >> >>The MimeMessageHelper already supports setting text/plain and text/html >>parts through the setText(String plainText, String htmlText) method and >>setText(String text, boolean html) methods. >> >>Regards, >>Alef >> >> >> >>>-----Original Message----- >>>From: spr...@li... >>>[mailto:spr...@li...] >>> On Behalf Of David Bowers >>>Sent: Tuesday, January 18, 2005 6:30 PM >>>To: spr...@li... >>>Subject: [Springframework-developer] common super-interface >>>in mail functionality >>> >>>I'm using the mail components to write a small framework >>>(apology for the way overused word) that can send either text >>>or html e-mails. To simplify this, it would be nice if there >>>were a common super-interface for >>>org.springframework.mail.SimpleMailMessage and >>>org.springframework.mail.javamail.MimeMessageHelper. They >>>both share getters and setters for properties like cc, to, >>>from, text, etc. It would be nice to be able to have common >>>initialization code regardless of whether I'm working with a >>>text or html message. >>> >>> >>>------------------------------------------------------- >>>The SF.Net email is sponsored by: Beat the post-holiday blues >>>Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. >>>It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt >>>_______________________________________________ >>>Springframework-developer mailing list >>>Spr...@li... >>>https://lists.sourceforge.net/lists/listinfo/springframework-developer >>> >>> >>> >>> >> >>------------------------------------------------------- >>The SF.Net email is sponsored by: Beat the post-holiday blues >>Get a FREE limited edition SourceForge.net t-shirt from ThinkGeek. >>It's fun and FREE -- well, almost....http://www.thinkgeek.com/sfshirt >>_______________________________________________ >>Springframework-developer mailing list >>Spr...@li... >>https://lists.sourceforge.net/lists/listinfo/springframework-developer >> > > > > > ------------------------------------------------------- > SF email is sponsored by - The IT Product Guide > Read honest & candid reviews on hundreds of IT Products from real users. > Discover which products truly live up to the hype. Start reading now. > http://ads.osdn.com/?ad_id=6595&alloc_id=14396&op=click |