Alternate ways to add recipients
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Andrew_Cook
Posted On:   Wednesday, November 6, 2002 06:51 AM

I am trying to use MimeMessage to send an e-mail from a programming language that cannot use member variables; it can only invoke Java functions. This means I cannot access the MimeMessage$RecipientType class correctly, and any recipient I add gives me an 'Invalid Recipient Type' exception. Can anyone suggest a way I can add recipients without using the AddRecipient method, perhaps using SetHeader for example? Please don't suggest that I switch to code in Java, since this is not an option. Now I could write a new Java class to encapsulate the JavaMail library, but that would mean another layer of code to support and deploy. Thanks in advance, Andy    More>>

I am trying to use MimeMessage to send an e-mail from a programming language that cannot use member variables; it can only invoke Java functions. This means I cannot access the MimeMessage$RecipientType class correctly, and any recipient I add gives me an 'Invalid Recipient Type' exception. Can anyone suggest a way I can add recipients without using the AddRecipient method, perhaps using SetHeader for example?



Please don't suggest that I switch to code in Java, since this is not an option. Now I could write a new Java class to encapsulate the JavaMail library, but that would mean another layer of code to support and deploy.



Thanks in advance,



Andy

   <<Less

Re: Alternate ways to add recipients

Posted By:   Christopher_Koenigsberg  
Posted On:   Wednesday, November 6, 2002 07:46 AM

An SMTP mail message has an "envelope" in addition to the message text. The "headers" are just part of the text, as far as SMTP is concerned. You could send a message with no "To:" header at all, as long as the recipients were specified in the SMTP envelope ("RCPT TO" field).



Typically mail clients will just assume you want to fill in the "To:" header with recipient addresses and then use those same addresses for the actual "RCPT TO" envelope field. But it doesn't have to work that way.



Maybe try Transport.send() or Transport.sendMessage(), where you supply the list of addresses as args? I assume this directly uses the args for the "RCPT TO" envelope field, and the javadoc for send() says "Send the message to the specified addresses, ignoring any recipients specified in the message itself.".

About | Sitemap | Contact