We are using licensed apose 6.7.0(jdk 1.6) to achieve the requirement of sending task to specified user.
Right now the task could be successfully created and sent out, but on receiving it, the 'on behalf of' message could not display the sender and the sent date.
attachment is the task received.
Before asking for help here, i already searched many materials but no result.
From the task result.png, you could see the first rectangle just show the on behalf of but no sender address, and the second rectangle show the wrong date and time.
String receiver = "example@example.com";
Calendar calendar = Calendar.getInstance();
Date startDate = calendar.getTime();
calendar.add(Calendar.DATE, 1);
Date endDate = calendar.getTime();
calendar.add(Calendar.DATE, -1);
Date reminderDate = calendar.getTime();
MapiTask task = new MapiTask(taskBean.getSubject(), "", startDate, endDate);
task.setBodyContent(taskBean.getBody(), 1);
task.setReminderSet(true);
task.setReminderTime(reminderDate);
task.setPercentComplete(0);
task.setEstimatedEffort(0);
task.setActualEffort(0);
task.getUsers().setAssigner(MapiElectronicAddress.to_MapiElectronicAddress(alertSenderEmail));
task.setHistory(MapiTaskHistory.Assigned);
task.getUsers().setOwner(receiver);
task.getUsers().setLastAssigner(alertSenderEmail);
task.getUsers().setLastDelegate(alertSenderEmail);
task.getUsers().setDelegator(alertSenderEmail);
task.getUsers().setOwnership(MapiTaskOwnership.AssignersCopy);
task.setSensitivity(MapiSensitivity.Personal);
task.setStatus(MapiTaskStatus.NotStarted);
task.save(path + "MapiTask.msg", TaskSaveFormat.Msg);
MailMessageLoadOptions loadOptions = new MailMessageLoadOptions();
loadOptions.setMessageFormat(MessageFormat.getMsg());
loadOptions.setFileCompatibilityMode(FileCompatibilityMode.PreserveTnefAttachments);
// load task from .msg file
MailMessage eml = MailMessage.load(path + "MapiTask.msg", loadOptions);
eml.setFrom(new MailAddress(alertSenderEmail));
eml.setSubject(taskBean.getSubject());
eml.getTo().clear();
eml.setReadReceiptTo(MailAddressCollection.to_MailAddressCollection(receiver));
eml.setSensitivity(MailSensitivity.Personal);
// send email to:
MailAddress address = new MailAddress(receiver);
MailAddressCollection addresses = new MailAddressCollection();
addresses.addMailAddress(address);
eml.setTo(addresses);
// We should cover all scenarios for delivery notification
eml.setDeliveryNotificationOptions(DeliveryNotificationOptions.OnSuccess | DeliveryNotificationOptions.OnFailure | DeliveryNotificationOptions.Delay);
SmtpClient client = new SmtpClient(smtpServerAddress, Integer.parseInt(smtpServerPort), "", "");
client.setConnectionTimeout(SMTP_CONNECTION_TIMEOUT);
client.setTimeout(SMTP_OPERATION_TIMEOUT);
Log.info("Task is ready to sent to receiver: " + receiver);
client.send(eml);
Log.info("Task was sent to receiver via " + smtpServerAddress);