SampleFiles.zip (82.5 KB)
Aspose Team,
We use the Aspose Email java package to extract msg from pst files and extract attachments from the extracted msg. Some pst files contain MS Teams messages and those messages may contain modern attachments that contain the URI of the shared link instead of the actual content. If we can get the URI we should be able to download the actual attachments. However, we cannot get the URI with Aspose Email.
Following is the sample code and attached are the sample files. The operating system is Ubuntu 20.04. Java version is 21. Aspose Email java packages is 24.5.
We can check if the attachment contains URI with the Attachment.isUri() method. And we can see the URI in the debugging information in IntelliJ (see below). We can even get the URI with the method attachment.f().a(). But this method is not public and we cannot use it in our program.
Wonder if you can make the method(s) attachment.f().a() public so that we can get URI from modern attachments.
Debugging information of Sample file 0_with_att.msg:
attachment:
result = {ReferenceAttachment@2401}
e = {zay@2402} “Sign in to your account Documents/Versions/100_Versions (1).docx”
f = 0
g = 0
d = null
Attachment.e = null
isUri = true
a = 0
Attachment.f = {ObjectIdentifier@2403}
Attachment.g = null
b = false
c = -1
AttachmentBase.a = {zaqo@2404}
AttachmentBase.d = true
attachment.getName():
result = “100_Versions (1).docx”
value = {byte[21]@2430} [49, 48, 48, 95, 86, 101, 114, 115, 105, 111, 110, 115, 32, 40, 49, 41, 46, 100, 111, 99, 120]
coder = 0
hash = 0
hashIsZero = false
attachment.f().a():
result = “Sign in to your account Documents/Versions/100_Versions (1).docx”
value = {byte[99]@2411} [104, 116, 116, 112, 115, 58, 47, 47, 101, 112, 105, 113, 115, 97, 110, 100, 98, 111, 120, 46, 115, 104, 97, 114, 101, 112, 111, 105, 110, 116, 46, 99, 111, 109, 47, 115, 105, 116, 101, 115, 47, 85, 71, 45, 69, 67, 67, 84, 101, 115, 116, 47, 83, 104, 97, 114, 101, 100, 32, 68, 111, 99, 117, 109, 101, 110, 116, 115, 47, 86, 101, 114, 115, 105, 111, 110, 115, 47, 49, 48, 48, 95, 86, 101, 114, 115, 105, 111, 110, 115, 32, 40, 49, 41, 46, 100, 111, 99, 120]
coder = 0
hash = 0
hashIsZero = false
Sample code:
import com.aspose.email.Attachment;
import com.aspose.email.MailMessage;
import com.aspose.email.MsgLoadOptions;
public class TeamsAttachment_31 {
public static void main(String[] args) {
try {
String inputMsg = "/home/ubuntu/winshare/00_Sample_Files/Archives/Pst_Teams/UG_ECCTest_extracted_selected/0_with_att.msg";
String outputDir = "/home/ubuntu/winshare/00_Sample_Files/Archives/Pst_Teams/UG_ECCTest_extracted_selected/outdir/";
MsgLoadOptions msgLoadOptions = new MsgLoadOptions();
msgLoadOptions.setPreserveEmbeddedMessageFormat(true);
MailMessage mailMessage = MailMessage.load(inputMsg, msgLoadOptions);
for (int i = 0; i < mailMessage.getAttachments().size(); i++) {
Attachment attachment = mailMessage.getAttachments().get_Item(i);
if(attachment != null) {
String outputFile = outputDir + "attachment_" + i;
attachment.save(outputFile);
Boolean isUri = attachment.isUri();
System.out.println("isUri = " + isUri);
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
}
}