sanjuT
01-31-2005, 10:36 AM
I use java servlets and have e-mails sent. I want to be able to catch any errors that might occur when the form data is sent to our AS/400 (OS 400).
the e-mails are sent from the AS/400 to our external e-mail server. I assume that if an error occured here (AS/400 >>> ext. e-mail server) I wouldn't be able to catch that error. So i just want to make sure that it at least gets to the AS/400 in fine shape.
How could I imlement this in the code below? This may be a stupid question, but i am not well versed in this.
THANKS!!
String msgText1="\r\n\r\n" + reqst + ", has submitted a Termination/Inactivation of User ID as follows:";
msgText1 = msgText1 +"\r\nREQUESTOR'S INFO:\r\n";
msgText1 = msgText1 + "\r\BLAH:\t\t" + date;
// create some properties and get the default Session
//Properties props = System.getProperties();
//props.put("mail.smtp.host", host);
//Session session = Session.getDefaultInstance(props, null);
try
{
// create a message
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("a@b.com"));
InternetAddress[] address = {new InternetAddress(to)};
//InternetAddress[] carbon = {new InternetAddress("c@d.com")};
InternetAddress[] carbon = {new InternetAddress("e@f.com")};
//InternetAddress[] blind = {new InternetAddress("g@h.com")};
msg.setRecipients(Message.RecipientType.TO, address);
//msg.setRecipients(Message.RecipientType.CC, carbon);
msg.addRecipients(Message.RecipientType.CC, carbon);
//msg.setRecipients(Message.RecipientType.BCC, blind);
//msg.setSubject("This e-mail goes to the HELPDESK");
msg.setSubject("Request for Termination/Inactivation of User ID");
msg.setSentDate(new Date());
// create and fill the first message part
msg.setText(msgText1);
Transport.send(msg);
}
catch (MessagingException mex)
{
mex.printStackTrace();
Exception ex = null;
if ((ex = mex.getNextException()) != null)
{
ex.printStackTrace();
}
}
the e-mails are sent from the AS/400 to our external e-mail server. I assume that if an error occured here (AS/400 >>> ext. e-mail server) I wouldn't be able to catch that error. So i just want to make sure that it at least gets to the AS/400 in fine shape.
How could I imlement this in the code below? This may be a stupid question, but i am not well versed in this.
THANKS!!
String msgText1="\r\n\r\n" + reqst + ", has submitted a Termination/Inactivation of User ID as follows:";
msgText1 = msgText1 +"\r\nREQUESTOR'S INFO:\r\n";
msgText1 = msgText1 + "\r\BLAH:\t\t" + date;
// create some properties and get the default Session
//Properties props = System.getProperties();
//props.put("mail.smtp.host", host);
//Session session = Session.getDefaultInstance(props, null);
try
{
// create a message
MimeMessage msg = new MimeMessage(session);
msg.setFrom(new InternetAddress("a@b.com"));
InternetAddress[] address = {new InternetAddress(to)};
//InternetAddress[] carbon = {new InternetAddress("c@d.com")};
InternetAddress[] carbon = {new InternetAddress("e@f.com")};
//InternetAddress[] blind = {new InternetAddress("g@h.com")};
msg.setRecipients(Message.RecipientType.TO, address);
//msg.setRecipients(Message.RecipientType.CC, carbon);
msg.addRecipients(Message.RecipientType.CC, carbon);
//msg.setRecipients(Message.RecipientType.BCC, blind);
//msg.setSubject("This e-mail goes to the HELPDESK");
msg.setSubject("Request for Termination/Inactivation of User ID");
msg.setSentDate(new Date());
// create and fill the first message part
msg.setText(msgText1);
Transport.send(msg);
}
catch (MessagingException mex)
{
mex.printStackTrace();
Exception ex = null;
if ((ex = mex.getNextException()) != null)
{
ex.printStackTrace();
}
}