You are viewing a plain text version of this content. The canonical link for it is here.
Posted to server-user@james.apache.org by "Brian J. Sayatovic" <tr...@one.net> on 2003/05/14 03:13:38 UTC

Compsing new mail from within Mailet

Using James 2.1.3, I have three isgnatures from which to choose in
Mailcontext to send a new message:

void sendMail(MailAddress sender, Collection recipients, InputStream msg) 
void sendMail(MailAddress sender, Collection recipients, MimeMessage msg) 
void sendMail(MimeMessage message)  

Each of these requires a MimeMessage object.  However, a MimeMessage can't
be constructed, as far as I can tell, without a Session.  So what can I do
to construct a new message for sending from within a mailet?

Regards,
Brian.

--
Help free our mailboxes. Include http://wecanstopspam.org in your signature.


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


Re: Compsing new mail from within Mailet

Posted by Cesar Bonadio <bo...@picture.com.br>.
Here is an example of how to compose a message inside a mailet


                MimeMessage newMessage = new
MimeMessage(Session.getDefaultInstance(System.getProperties(), null));

                newMessage.setSubject( "Test" );
                newMessage.setFrom( "test@tst.com");

                // monta a resposta
                newMessage.setText("balbla balala ala " );

                MailAddress from = mail.getSender() ;
                newMessage.setRecipients( MimeMessage.RecipientType.TO,
from.toString() );

                Them you send as a normal email using the transpot



----- Original Message -----
From: "Serge Knystautas" <se...@lokitech.com>
To: "James Users List" <ja...@jakarta.apache.org>
Sent: Wednesday, May 14, 2003 10:00 AM
Subject: Re: Compsing new mail from within Mailet


> Brian J. Sayatovic wrote:
> > Using James 2.1.3, I have three isgnatures from which to choose in
> > Mailcontext to send a new message:
> >
> > void sendMail(MailAddress sender, Collection recipients, InputStream
msg)
> > void sendMail(MailAddress sender, Collection recipients, MimeMessage
msg)
> > void sendMail(MimeMessage message)
> >
> > Each of these requires a MimeMessage object.  However, a MimeMessage
can't
> > be constructed, as far as I can tell, without a Session.  So what can I
do
> > to construct a new message for sending from within a mailet?
>
> Eh, Brian, well, the first method you list does not take a MimeMessage.
>   I still wouldn't do that though.  Just get a Session and construct a
> MimeMessage like normal.  See the examples that come with JavaMail as
> they show how to create a MimeMessage easily enough.
>
> --
> Serge Knystautas
> President
> Lokitech >> software . strategy . design >> http://www.lokitech.com/
> p. 1.301.656.5501
> e. sergek@lokitech.com
>
>
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: james-user-unsubscribe@jakarta.apache.org
> For additional commands, e-mail: james-user-help@jakarta.apache.org
>
>


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


Re: Compsing new mail from within Mailet

Posted by Serge Knystautas <se...@lokitech.com>.
Brian J. Sayatovic wrote:
> Using James 2.1.3, I have three isgnatures from which to choose in
> Mailcontext to send a new message:
> 
> void sendMail(MailAddress sender, Collection recipients, InputStream msg) 
> void sendMail(MailAddress sender, Collection recipients, MimeMessage msg) 
> void sendMail(MimeMessage message)  
> 
> Each of these requires a MimeMessage object.  However, a MimeMessage can't
> be constructed, as far as I can tell, without a Session.  So what can I do
> to construct a new message for sending from within a mailet?

Eh, Brian, well, the first method you list does not take a MimeMessage. 
  I still wouldn't do that though.  Just get a Session and construct a 
MimeMessage like normal.  See the examples that come with JavaMail as 
they show how to create a MimeMessage easily enough.

-- 
Serge Knystautas
President
Lokitech >> software . strategy . design >> http://www.lokitech.com/
p. 1.301.656.5501
e. sergek@lokitech.com



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