We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

setDeliveryNotificationOptions in MailMessage

Dear,

I am encountering one question when using the com.aspose.email.MailMessage,
it has one method named
<h3 style=“box-sizing: border-box; font-family: “DejaVu Sans Mono”, Georgia, “Times New Roman”, Times, serif; font-weight: 500; line-height: 1.1; color: rgb(51, 51, 51); margin-top: 20px; margin-bottom: 10px; font-size: 24px;”>setDeliveryNotificationOptions,
if we would like to support the notification in both Success and Failure, how we could achieve this in java?

Hi,

Thank you for posting your inquiry.

Please have a look at the following sample code for example fulfilling your requirements and let us know if we can be of any additional help to you in this regard.

Sample Code:

MailMessage mail = new MailMessage("sender@domain.com", "INVALID_EMAIL_ADDRESS@domain.com",“Test mail with both notifications”,“Test body”);

mail.getTo().add("VALID_EMAIL_ADDRESS@domain.com");

mail.setDeliveryNotificationOptions(DeliveryNotificationOptions.OnSuccess| DeliveryNotificationOptions.OnFailure);

SmtpClient smtpClient = new SmtpClient(“[exchange.domain.com](http://exchange.domain.com/)”, "sender@domain.com", “password”);

smtpClient.send(mail);