We're sorry Aspose doesn't work properply without JavaScript enabled.

Free Support Forum - aspose.com

Add MailMessage object as an attachment to other MailMessaage

I have derived MailMessage object

public class MailMessage : Aspose.Email.Mail.MailMessage
{
public Guid ParentId { get; set; }
public Guid Id { get; set; }
public string FilePath { get; set; }
}

I am creating list of MailMessages and saving all MailMessage objects in it. As you can see, I am keeping track of which message is attached to which mail message by ParentId. I am reconstructing the tree as follows:

foreach (var msgAndAttachedEmail in _msgAndAttachedEmails)
{
Trace.Main.verbose(“Total eml files : {}”, _msgAndAttachedEmails.Count);
var parent =
_msgAndAttachedEmails.FirstOrDefault( x => x.Id == msgAndAttachedEmail.ParentId);
if (null != parent)
{
Trace.Main.verbose(“attaching {} to {}”,
msgAndAttachedEmail.Id.ToString(),
parent.Id.ToString());
AddMailAttachment(ref parent,msgAndAttachedEmail.FilePath);
}
}

I want to create a .eml file preserving this tree/hierarchy. One obvious way is attaching MailMessage to other message as an attachment and let library worry about persisting it. I am not sure Aspose library can do that. This can be a feature.

Is it possible? If yes, how?

Reply if you want more information

Hi Jason,

Thank you for contacting Aspose support team.

I have analyzed your requirements and would like to share that currently no such feature is available in Aspose.Email which can fulfil this particular requirement. As it is a specific requirement, it has to be achieved programmatically as you have done in your sample code. I am afraid that no such new feature can be provided in Aspose.Email.

Please feel free to write us back if you have any other query related to Aspose.Email.