By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,034 Members | 822 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,034 IT Pros & Developers. It's quick & easy.

[JAVAMAIL 1.3.1][SDK 1.4.2_04] - Cc-Header

P: n/a
hi together.

public void sendMail(String body, String subject, String sender, String to,
String copy) {
String server = "";
String toList = null;
Properties props = new Properties();

props.put("", server);
props.put("mail.smtp.sendpartial", "true");
Session session = Session.getDefaultInstance(props, null);

try {
InternetAddress from = new InternetAddress(sender,true);
InternetAddress[] replyto = {new InternetAddress(sender,true)};
InternetAddress[] sendto = {new InternetAddress(to)};
Object objBody = new String(body);

MimeMessage myMsg = new MimeMessage(session);
DataHandler myData = new DataHandler(objBody,

URLName myURL = new
SMTPTransport myTra = new SMTPTransport(session, myURL);

if (copy != null) {
InternetAddress[] copyto = {new InternetAddress(copy)};
myMsg.setRecipients(Message.RecipientType.CC, copyto);

myMsg.setHeader("X-Mailer", "Applet Best-1.000-04/2004");
myMsg.setSentDate(new java.util.Date());
myMsg.setSubject(subject, "iso-8859-1");

SMTPMessage smtpMsg = new SMTPMessage((MimeMessage) myMsg);

myTra.sendMessage(smtpMsg, sendto);
catch (MessagingException mex) {
Exception ex = null;
if ((ex = mex.getNextException()) != null) {

those function send mail and works, except the copyto user. he gets no mail.
the mail looks...:

Return-Path: <replyto>
Delivered-To: from
Received: from ( [])
by (Postfix) with ESMTP id BF02B9A404D
for <sendto>; Wed, 21 Apr 2004 11:28:36 +0200 (CEST)
Received: from localhost ( [])
by (8.11.6/8.11.6) with ESMTP id i3L9STr03234
for <sendto>; Wed, 21 Apr 2004 11:28:29 +0200
Message-ID: <5626111.1082539715500.JavaMail.javamailuser@local host>
Date: Wed, 21 Apr 2004 11:28:35 +0200 (CEST)
From: from Reply-To: replyto
Subject: Bestellung Artikel
Cc: copyto
Mime-Version: 1.0
Content-Type: text/plain; charset=Cp1252
Content-Transfer-Encoding: quoted-printable
X-Mailer: JavaClient/Applet Best-1.000-04/2004


i have changed the mail system values to the var names in the source, they
are ok.
the header sequence is unchanged.

a look in source shows, that the cc-header is in third place, if exists.
in the produced mail the cc-header is behind the subject-header. causes
these the trouble?

thanks in advance
Jul 17 '05 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.