Hi Support Team,
We have an in-house application that checks the mails in the mailbox and sees if we failed to ingest any mails or attachments. So recently, I have run into an issue where while comparing the attachments that we ingested successfully, the count from Aspose showing higher as it is also counting the image of the company’s logo that some people attach in their mail
I supposed this is due to the fact that it also counts the images in the body as attachment. I have attached pieces of the code I am using below, can you please tell me how I can get the count of only actually attached attachments and exclude the inline attachments while iterating through the list of attachments in the line:
foreach (ExchangeAttachmentInfo attachment in attachmentInfo)
This is the sample code explaining what I am trying to do:
ExchangeFolderInfo subfolderInfo = new ExchangeFolderInfo();
ExchangeQueryBuilder builder = new ExchangeQueryBuilder();
builder.InternalDate.Since(from, DateComparisonType.ByDateTime);
builder.InternalDate.BeforeOrEqual(to, DateComparisonType.ByDateTime);
MailQuery query = builder.GetQuery();
ExchangeMessageInfoCollection messages = client.ListMessages(mailboxInfo.InboxUri, query);
if (messages.Count > 0)
{
//For each email in the mailbox
foreach (ExchangeMessageInfo msgInfo in messages)
{
if (!(msgInfo.Subject == null))
{
//Creating new Mail template to store mail info
EmailObjectModel emailMailBox = new emailMailBox();
//MessageInfo is of the type ExchangeMessageInfo
emailMailBox.MessageInfo = msgInfo;
ExchangeAttachmentInfoCollection attachmentInfo = new ExchangeAttachmentInfoCollection();
//Get attachments from the source mailbox mail
attachmentInfo = emailMailBox.MessageInfo.Attachments;
//If there is a mismatch in ingested attachment count from mailbox mail attachment count
if (attachmentInfo.Count != IngestedAttachments.Count)
{
foreach (ExchangeAttachmentInfo attachment in attachmentInfo)
{
//Below code checks if the attachment has been ingested in DB
var attchmnt = from parent in attachmentList
where parent.Doctitle == attachment.Name
&& parent.IsParent == 0
select parent;
//If the attachment was not ingested, get attachment and put it in ICC path
if (attchmnt.Count() == 0 || attchmnt == null)
{
//Extracting the missing Attachment and placing in ICC source path
Attachment att = emailMailBox.client.FetchAttachment(attachment.AttachmentUri);
att.Save(@ICCPath + attachment.Name);
}
}
}
}
}
}