[opencms-dev] About newsletter
Vardan Gevorgyan
vgevorgy at sourcio.com
Mon Jul 10 13:08:04 CEST 2006
Does it must work?
<%@ page session="false" import="org.opencms.newsletter.*,
org.opencms.jsp.*, java.util.*" %>
<%
CmsNewsletterDistributor send_mail = new CmsNewsletterDistributor();
out.println("making distributer");
CmsJspActionElement cmsa = new CmsJspActionElement(pageContext, request,
response);
out.println("making cms object");
CmsSimpleNewsletterRecipient[] to = new CmsSimpleNewsletterRecipient[2];
to[0] = new CmsSimpleNewsletterRecipient("mail1","Name1");
to[1] = new CmsSimpleNewsletterRecipient("mail2","Name2");
List em = Arrays.asList(to);
out.println("making recipient list");
CmsNewsletter letter = new CmsNewsletter();
CmsNewsletterContent letterContent = new
CmsNewsletterContent(1,"Hello!!!", CmsNewsletterContentType.TYPE_HTML);
letter.addContent(letterContent);
letter.setSubject("OpenCMS newletter text");
out.println("making letter");
send_mail.distribute(cmsa.getCmsObject(), em, letter);
out.println("message was sent");
%>
It does not work. :)
Sebastian Himberger wrote:
> Hi,
>
> seems like a bug in CmsNewsletter. The Mail is always casted into an
> CmsHtmlMail wich fails if you try to send text mails (what you did).
> Have a look at
> http://www.opencms.org/cvs/viewcvs.cgi/opencms/src/org/opencms/newsletter/CmsNewsletter.java?rev=1.2&content-type=text/vnd.viewcvs-markup
> These lines seems to be the problem.:
>
> } else {
> // only text content, return text mail
> email = new CmsSimpleMail();
> }
> ((CmsHtmlMail)email).setTextMsg(replaceMacros(txtMsg.toString(),
> recipient));
> email.addTo(recipient.getEmail());
> email.setSubject(m_subject);
> return email;
>
>
> Maybe it helps to just remove the cast. Do you have a bugzilla account
> to fill a bugreport? If not, send me a note so i can do it. For a
> workaround try sending html mails.
>
> HTH
> Sebastian
>
> Vardan Gevorgyan schrieb:
>> Hello
>>
>> How can use CmsNewsletterDistributor?
>> I have tried like this:
>>
>> <%@ page session="false" import="org.opencms.newsletter.*,
>> org.opencms.jsp.*, java.util.*" %>
>>
>> <%
>> CmsNewsletterDistributor send_mail = new CmsNewsletterDistributor();
>> out.println("making distributer");
>>
>> CmsJspActionElement cmsa = new CmsJspActionElement(pageContext,
>> request, response);
>> out.println("making cms object");
>>
>> CmsSimpleNewsletterRecipient[] to = new CmsSimpleNewsletterRecipient[1];
>> to[0] = new CmsSimpleNewsletterRecipient("my_email","my_name");
>> List em = Arrays.asList(to);
>> out.println("making recipient list");
>>
>> CmsNewsletter letter = new CmsNewsletter();
>> CmsNewsletterContent letterContent = new
>> CmsNewsletterContent(1,"Hello!!!", CmsNewsletterContentType.TYPE_TEXT);
>> letter.addContent(letterContent);
>> letter.setSubject("OpenCMS newletter text");
>> out.println("making letter");
>>
>> send_mail.distribute(cmsa.getCmsObject(), em, letter);
>> out.println("message was sent");
>> %>
>>
>> _______________________________________________
>> This mail is sent to you from the opencms-dev mailing list
>> To change your list options, or to unsubscribe from the list, please
>> visit
>> http://lists.opencms.org/mailman/listinfo/opencms-dev
>
>
> _______________________________________________
> This mail is sent to you from the opencms-dev mailing list
> To change your list options, or to unsubscribe from the list, please
> visit
> http://lists.opencms.org/mailman/listinfo/opencms-dev
>
More information about the opencms-dev
mailing list