Results 1 to 6 of 6
- 07-09-2009, 09:28 AM #1
Member
- Join Date
- Jul 2009
- Posts
- 18
- Rep Power
- 0
- 07-09-2009, 10:45 AM #2
hi Sateesh,
Gothru this api and send method below
Transport (Java 2 Platform Ent. Ed. v1.4))
send
public static void send(Message msg)
throws MessagingExceptionSend a message. The message will be sent to all recipient addresses specified in the message (as returned from the Message method getAllRecipients), using message transports appropriate to each address. The send method calls the saveChanges method on the message before sending it.
If any of the recipient addresses is detected to be invalid by the Transport during message submission, a SendFailedException is thrown. Clients can get more detail about the failure by examining the exception. Whether or not the message is still sent succesfully to any valid addresses depends on the Transport implementation. See SendFailedException for more details. Note also that success does not imply that the message was delivered to the ultimate recipient, as failures may occur in later stages of delivery. Once a Transport accepts a message for delivery to a recipient, failures that occur later should be reported to the user via another mechanism, such as returning the undeliverable message.
Parameters:
msg - the message to send
Throws:
SendFailedException - if the message could not be sent to some or any of the recipients.
MessagingException
See Also:
Message.saveChanges(), Message.getAllRecipients(), send(Message, Address[]), SendFailedException
Ramya:cool:
- 07-09-2009, 12:06 PM #3
Member
- Join Date
- Jul 2009
- Posts
- 18
- Rep Power
- 0
Hi Ramya,
thanks:) but i hav already tried SendFailedException and MessagingException class.. actually this exception is not thrown even though i give some non-exitence recipient address..
code wat i tried is
// create a message
Message msg = new MimeMessage(session);
// set the from and to address
StringBuilder smtpFrom = new StringBuilder();
String from = map.get("partnerName") == null? "" : (String)map.get("partnerName");
if (! from.equals("")) {
smtpFrom.append(from).append(" ");
}
smtpFrom.append("<");
smtpFrom.append(MailUtils.getSmtpFrom()).append("> ");
log.info("Sent mailer");
log.info(smtpFrom.toString());
log.info("Sent mailer");
msg.setFrom(new InternetAddress(smtpFrom.toString()));
final String sendReportTo = (String) map.get("sendReportTo");
msg.setRecipients(Message.RecipientType.TO,
getInternetAddressArrayFromStringOfAddress(sendRep ortTo));
final String cc = (String) map.get("cc");
if (!"".equals(cc.trim())) {
msg.setRecipients(Message.RecipientType.CC,
getInternetAddressArrayFromStringOfAddress(cc));
}
final String bcc = (String) map.get("bcc");
if (!"".equals(bcc.trim())) {
msg.setRecipients(Message.RecipientType.BCC,
getInternetAddressArrayFromStringOfAddress(bcc));
}
final String subject = (String) map.get("subject");
// msg.setHeader("Subject", subject);
msg.setSubject(subject);
final String key = (String) map.get("key");
msg.setHeader("Message-ID",key);
//msg.setHeader("References",key);
Multipart multipart = new MimeMultipart();
//
// Set the email message text.
//
final String content = (String) map.get("content");
MimeBodyPart messagePart = new MimeBodyPart();
// messagePart.setText(content);
messagePart.setContent(content,"text/html; charset=UTF-8");
multipart.addBodyPart(messagePart);
//
// Set the email attachment files
//
if(map.get("bodyParts")!=null){
List<MimeBodyPart> bodyParts = (List<MimeBodyPart>) map.get("bodyParts");
for (MimeBodyPart mimeBodyPart : bodyParts) {
multipart.addBodyPart(mimeBodyPart);
//multipart.getBodyPart(index)
}
}
// add the Multipart to the message
msg.setContent(multipart);
log.info(" ** before transport");
//msg.addHeader("key", arg1)
try { Transport.send(msg);
} catch(SendFailedException sendFailedException) {
log.info(" ** ValidUnsent Addresses");
Address[] validUnsent =
sendFailedException.getValidUnsentAddresses();
if (validUnsent != null) {
log.info(" ** ValidUnsent Addresses");
if (validUnsent != null) {
for (int i = 0;
i < validUnsent.length; i++)
log.info(" "+validUnsent[i]);
}
}
}
Enumeration<Header> enumSent=msg.getAllHeaders();
while(enumSent.hasMoreElements()){
Header h = (Header) enumSent.nextElement();
if(h.getName().equalsIgnoreCase("Message-ID")){
sentKey=h.getValue();
}
}
} catch (MessagingException e) {
log.info(e.getMessage());
log.error("Cann't send report via e-mail: some errors", e);
}
- 07-09-2009, 12:07 PM #4
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
- 07-09-2009, 12:42 PM #5
Member
- Join Date
- Jul 2009
- Posts
- 18
- Rep Power
- 0
Hi Tolls,
ok we cannot determine the existence of an email address.. but is there any way to determine undeliverd emails
- 07-09-2009, 12:57 PM #6
Moderator
- Join Date
- Apr 2009
- Posts
- 10,484
- Rep Power
- 16
Similar Threads
-
Image Verification
By peiceonly in forum Java ServletReplies: 2Last Post: 04-04-2009, 07:38 AM -
username password verification
By bheezee in forum JDBCReplies: 0Last Post: 11-25-2008, 06:55 PM -
send email using apache commons email
By jnamendi in forum JavaServer Faces (JSF)Replies: 0Last Post: 10-14-2008, 05:55 PM -
Input Verification Dialog Demo
By Java Tip in forum javax.swingReplies: 0Last Post: 06-26-2008, 07:43 PM -
Input Verification Demo
By Java Tip in forum javax.swingReplies: 0Last Post: 06-26-2008, 07:42 PM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks