You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@commons.apache.org by Mathias Berg <ma...@gmail.com> on 2006/12/19 09:51:36 UTC

[EMAIL] - Sending both text plain and html.

Hi, if im not misstaken common-email can  send both a body part with a
plain text and a body part of html in one mail. So the reciever either
get the text or html depending on the recievers email client settings.

Is this true?

Then second question how to i impl that. Like this?

Tx for any help.
....................

org.apache.commons.mail.Email email;
        if (emailConfig.isHtml()) {
            email = new HtmlEmail();
        } else {
            email = new SimpleEmail();
        }

......

if (emailConfig.isHtml() && email instanceof HtmlEmail) {
    ((HtmlEmail)email).setHtmlMsg(emailConfig.getHtmlMessage());
}
email.setMsg("Text plain text");

...

email.buildMimeMessage();
email.send();

........................................

Best regards, Mathias.

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [EMAIL] - Sending both text plain and html.

Posted by "C.Grobmeier" <gr...@possessed.de>.
Hi,

> Yes apaches tutorial is great, but it think it could be a bit more
> deeper infos.

you mean UML or stuff like this? As far as i know is Commons Email is based on the Sun Email classes so going deeper into commons means going deeper into the suns mail api.

> Do you know how to add many attachemnts using EmailAttachemnt class
> for one mail? I can see how to make for one attachment, but not
> multiple.

I think it is:

EmailAttachment attachment = new EmailAttachment();
attachment.setPath("mypictures/john.jpg");
...

EmailAttachment attachment2 = new EmailAttachment();
attachment2.setPath("mypictures/john.jpg");
...

// Create the email message
MultiPartEmail email = new MultiPartEmail();
email.attach(attachment);
email.attach(attachment2);

Cheers,
Chris

> 
> Regards, Mathias.
> 
> 2006/12/19, C. Grobmeier <gr...@possessed.de>:
>>
>> > Do you know any more sites other then apache that have tutorials for
>> > common-email?
>>
>> Well actually i don't know any other sites. I always thought the example
> section is quite complete :-)
>>
>> Cheers
>> Chris
>>
>> >
>> > /Mathias
>> >
>> > 2006/12/19, C. Grobmeier <gr...@possessed.de>:
>> >>
>> >> Hi,
>> >>
>> >> > Hi, if im not misstaken common-email can  send both a body part
> with a
>> >> > plain text and a body part of html in one mail. So the reciever
> either
>> >> > get the text or html depending on the recievers email client
> settings.
>> >> > Is this true?
>> >> > Then second question how to i impl that. Like this?
>> >>
>> >> You need HTML-Messages. Visit this:
>> >> http://jakarta.apache.org/commons/email/userguide.html
>> >> and search for "HTML formatted email". You will see the following:
>> >>
>> >> HtmlEmail email = new HtmlEmail();
>> >> // set the html message
>> >> email.setHtmlMsg("<html>The apache logo - <img
>> > src=\"cid:"+cid+"\"></html>");
>> >> // set the alternative message
>> >> email.setTextMsg("Your email client does not support HTML messages");
>> >>
>> >> That should do fine.
>> >> Cheers,
>> >> Chris
>> >>
>> >>
>> >> ---------------------------------------------------------------------
>> >> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> >> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>> >>
>> >>
>> >
>> > ---------------------------------------------------------------------
>> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [EMAIL] - Sending both text plain and html.

Posted by Mathias Berg <ma...@gmail.com>.
Yes apaches tutorial is great, but it think it could be a bit more
deeper infos.
Do you know how to add many attachemnts using EmailAttachemnt class
for one mail? I can see how to make for one attachment, but not
multiple.

Regards, Mathias.

2006/12/19, C. Grobmeier <gr...@possessed.de>:
>
> > Do you know any more sites other then apache that have tutorials for
> > common-email?
>
> Well actually i don't know any other sites. I always thought the example section is quite complete :-)
>
> Cheers
> Chris
>
> >
> > /Mathias
> >
> > 2006/12/19, C. Grobmeier <gr...@possessed.de>:
> >>
> >> Hi,
> >>
> >> > Hi, if im not misstaken common-email can  send both a body part with a
> >> > plain text and a body part of html in one mail. So the reciever either
> >> > get the text or html depending on the recievers email client settings.
> >> > Is this true?
> >> > Then second question how to i impl that. Like this?
> >>
> >> You need HTML-Messages. Visit this:
> >> http://jakarta.apache.org/commons/email/userguide.html
> >> and search for "HTML formatted email". You will see the following:
> >>
> >> HtmlEmail email = new HtmlEmail();
> >> // set the html message
> >> email.setHtmlMsg("<html>The apache logo - <img
> > src=\"cid:"+cid+"\"></html>");
> >> // set the alternative message
> >> email.setTextMsg("Your email client does not support HTML messages");
> >>
> >> That should do fine.
> >> Cheers,
> >> Chris
> >>
> >>
> >> ---------------------------------------------------------------------
> >> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> >> For additional commands, e-mail: commons-user-help@jakarta.apache.org
> >>
> >>
> >
> > ---------------------------------------------------------------------
> > To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> > For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [EMAIL] - Sending both text plain and html.

Posted by "C.Grobmeier" <gr...@possessed.de>.
> Do you know any more sites other then apache that have tutorials for
> common-email?

Well actually i don't know any other sites. I always thought the example section is quite complete :-)

Cheers
Chris

> 
> /Mathias
> 
> 2006/12/19, C. Grobmeier <gr...@possessed.de>:
>>
>> Hi,
>>
>> > Hi, if im not misstaken common-email can  send both a body part with a
>> > plain text and a body part of html in one mail. So the reciever either
>> > get the text or html depending on the recievers email client settings.
>> > Is this true?
>> > Then second question how to i impl that. Like this?
>>
>> You need HTML-Messages. Visit this:
>> http://jakarta.apache.org/commons/email/userguide.html
>> and search for "HTML formatted email". You will see the following:
>>
>> HtmlEmail email = new HtmlEmail();
>> // set the html message
>> email.setHtmlMsg("<html>The apache logo - <img
> src=\"cid:"+cid+"\"></html>");
>> // set the alternative message
>> email.setTextMsg("Your email client does not support HTML messages");
>>
>> That should do fine.
>> Cheers,
>> Chris
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
>> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>>
>>
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [EMAIL] - Sending both text plain and html.

Posted by Mathias Berg <ma...@gmail.com>.
tx. it works :-)

Do you know any more sites other then apache that have tutorials for
common-email?

/Mathias

2006/12/19, C. Grobmeier <gr...@possessed.de>:
>
> Hi,
>
> > Hi, if im not misstaken common-email can  send both a body part with a
> > plain text and a body part of html in one mail. So the reciever either
> > get the text or html depending on the recievers email client settings.
> > Is this true?
> > Then second question how to i impl that. Like this?
>
> You need HTML-Messages. Visit this:
> http://jakarta.apache.org/commons/email/userguide.html
> and search for "HTML formatted email". You will see the following:
>
> HtmlEmail email = new HtmlEmail();
> // set the html message
> email.setHtmlMsg("<html>The apache logo - <img src=\"cid:"+cid+"\"></html>");
> // set the alternative message
> email.setTextMsg("Your email client does not support HTML messages");
>
> That should do fine.
> Cheers,
> Chris
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: commons-user-help@jakarta.apache.org
>
>

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org


Re: [EMAIL] - Sending both text plain and html.

Posted by "C.Grobmeier" <gr...@possessed.de>.
Hi, 

> Hi, if im not misstaken common-email can  send both a body part with a
> plain text and a body part of html in one mail. So the reciever either
> get the text or html depending on the recievers email client settings.
> Is this true?
> Then second question how to i impl that. Like this?

You need HTML-Messages. Visit this:
http://jakarta.apache.org/commons/email/userguide.html
and search for "HTML formatted email". You will see the following:

HtmlEmail email = new HtmlEmail();
// set the html message
email.setHtmlMsg("<html>The apache logo - <img src=\"cid:"+cid+"\"></html>");
// set the alternative message
email.setTextMsg("Your email client does not support HTML messages");

That should do fine.
Cheers,
Chris


---------------------------------------------------------------------
To unsubscribe, e-mail: commons-user-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-user-help@jakarta.apache.org