Ews Я читаю почту и хочу вернуть почтовые вложения.Я хочу, чтобы веб-интерфейс перечислял вложения, и я хочу, чтобы они загружались при нажатии.Так что я должен вернуть?
public List<MailResponseDto> readEmailItem(ItemId itemId) {
MailResponseDto messageData = new MailResponseDto();
List<String> downloadFileNames = new ArrayList<>();
List<MailResponseDto> mailResponseDtos = new ArrayList<>();
try {
Item itm = Item.bind(service, itemId, PropertySet.FirstClassProperties);
EmailMessage emailMessage = EmailMessage.bind(service, itm.getId());
messageData.setEmailItemId(emailMessage.getId().toString());
messageData.setSubject(emailMessage.getSubject());
messageData.setFromAddress(emailMessage.getFrom().getAddress());
messageData.setSenderName(emailMessage.getSender().getName().toString());
Date dateTimeCreated = emailMessage.getDateTimeCreated();
messageData.setSendDate(dateTimeCreated.toString());
Date dateTimeRecieved = emailMessage.getDateTimeReceived();
messageData.setRecievedDate(dateTimeRecieved.toString());
messageData.setSize(emailMessage.getSize());
messageData.setEmailBody(emailMessage.getBody().toString());
mailResponseDtos.add(messageData);
if (emailMessage.getHasAttachments()) {
AttachmentCollection attachmentsCol = itm.getAttachments();
for (int i = 0; i < attachmentsCol.getCount(); i++) {
FileAttachment attachment = (FileAttachment)
attachmentsCol.getPropertyAtIndex(i);
attachment.load(mailProperty.getSaveDirectory() + attachment.getName());
downloadFileNames.add(attachment.getName());
}
}
} catch (Exception e) {
e.printStackTrace();
}
return mailResponseDtos;
}
и MailResponseDto;
MailResponseDto
public class MailResponseDto {
private String emailItemId;
private String subject;
private String fromAddress;
private String senderName;
private String sendDate;
private String recievedDate;
private int size;
private String emailBody;
private List<File> files;
}