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 = "srv.domain.com";
String toList = null;
Properties props = new Properties();

props.put("mail.smtp.host", 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,
"text/plain");

URLName myURL = new
URLName("SMTP",server,-1,"","applet","");
SMTPTransport myTra = new SMTPTransport(session, myURL);

myMsg.setReplyTo(replyto);
myMsg.setFrom(from);
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");
myMsg.setDataHandler(myData);

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

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

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 srv.domain.com (srv.domain.com [192.168.1.45])
by mail.domain.com (Postfix) with ESMTP id BF02B9A404D
for <sendto>; Wed, 21 Apr 2004 11:28:36 +0200 (CEST)
Received: from localhost (dv02na.domain.com [192.168.1.70])
by srv.domain.com (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
volker
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.