Hi All, I know this question does not pertain to Java3D but if anyone could kindly give some suggestions, it would be highly appreciated.
 
I have been trying to send an E-mail through an Applet but haven't been quite successful. I have tried out a lot of code and even downloaded a few samples but none of them seem to work. I am getting an "Unable to connect to Host exception". Running the same code as an application, the mail is sent successfully. Could anyone please direct me where i am going wrong? Any code snippet would definitely help.
 
I used the following code:
 
/**********************************************************************************/
 
Properties props = new Properties();
// host is the SMTP server Address.
props.put("mail.smtp.host", host);
 
// Get session
Session session = Session.getInstance(props, null);

// Define message
Message message = new MimeMessage(session);
message.setFrom(new InternetAddress(from));
toAddress = splitAddress(to);
message.setRecipients(Message.RecipientType.TO,
toAddress);
message.setSubject(subject);

// Create the message part
BodyPart messageBodyPart = new MimeBodyPart();

// Fill the message
messageBodyPart.setText(content);

// Create a Multipart
Multipart multipart = new MimeMultipart();

// Add part one
multipart.addBodyPart(messageBodyPart);

//
// Part two is attachment
//

// Create second body part
messageBodyPart = new MimeBodyPart();

// Get the attachment
DataSource source = new FileDataSource(redFileName);

// Set the data handler to the attachment
messageBodyPart.setDataHandler(new DataHandler (source));

// Set the filename
messageBodyPart.setFileName(redFileName);

// Add part two
multipart.addBodyPart(messageBodyPart);

// Put parts in message
message.setContent(multipart);

try
{
Transport.send(message);
}catch(MessagingException msge)
{
msge.printStackTrace();
}
/**********************************************************************************/
 
Do i need to use a signed Applet?
 
Thanks in advance
regards
Vijayan Pandalai.

Reply via email to