문제

In EWS, the EmailMessage has a sender (emailMessage.getSender()) and may has attachments (emailMessage.getAttachments()).

These attachments can be FileAttachment (for files) or ItemAttachment (for attached email).

There is a lot of information on this item attachment such as :

But how to find the sender of this attached email ?

Edit : Using EWS Java API 1.1.5 http://archive.msdn.microsoft.com/ewsjavaapi/Release/ProjectReleases.aspx?ReleaseId=5754

도움이 되었습니까?

해결책 2

Following the SliverNinja response, I tried to retrieve the item as an email message. Using EWS with Java, you have to cast the item ItemAttachment as EmailMessage like this:

Item item = ((ItemAttachment) attachment).getItem();
if (item instanceof EmailMessage) {
    String sender = ((EmailMessage)item).getSender().getAddress();
}

The item can also be cast as Appointment or Contact or Task or ContactGroup.

Edit : Another way to get the sender is

((EmailMessage) item).getFrom().getAddress();

This looks like to do the same

다른 팁

In c# - you could access the ItemAttachment.Message and then Message.Sender. Once you have the sender, you can retrieve Sender.Mailbox for accessing the Mailbox.EmailAddress. Maybe you can convert this to something similar for java.

ItemAttachment itemAttachment = attachment as ItemAttachment;
itemAttachment.Load();
Sender sender = itemAttachment.Message.Sender;
Mailbox mailbox = sender.Mailbox;
string email = mailbox.EmailAddress;
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top