Free Support Forum - aspose.com

Proble with an attached Mail saved over Aspose

Hi.

We load mails via drag&drop from Outlook in our app. Everything works just fine, but there is one strange thing with it.

I drag&drop some mail, which has another mail attached. Then, because we send the files over the wire, we save the messages to a MemoryStream like this:

mapiMessage.Save(MessageStream);

And at the end we get .msg files, that are readable with outlook, everything seems to be fine BUT you can’t do “Send To -> E-Mail receipient” on the attachment mail over the Windows Explorer with right click. This works only for the main mail, not for attached mails.

I have attached 2 example mails.

If someone has an idea please get me know.

Hi,

Thank you for your interest in Aspose.Email.

stasgisin3:
Hi.

BUT you can't do "Send To -> E-Mail receipient" on the attachment mail over the Windows Explorer with right click. This works only for the main mail, not for attached mails.


Can you please tell us if the "Send To-> Mail Recipient" option is not available in windows explorer or the option is there but the mail is not sent to recipients? I have downloaded your attached emails but as it's not intended for me, so I can't confirm if this functionality is working or not? Also, does this happen with drag&dropped emails or with any other email as well created through code?

Hi,

the option in Windows Explorer is available, but when I click it nothing happens.

We does not create emails and do not need this functionality, so I can’t tell you, if the problem is also for created mails.

For us the problem exists only in this scenario (maybe we just do something wrong):

1. Drag&Drop from Outlook an email, which has another email attached
2. Read this with Aspose in a MapiMessage: mMapiMessage = MapiMessage.FromStream(stream);
3. Save attachments:
foreach (var attachment in mMapiMessage.Attachments)
{
MemoryStream content = new MemoryStream(attachment.BinaryData ?? attachment.ObjectData.Data);
writeFileToDisk(content, attachment.LongFileName);
}

Hi,

I tried to reproduce the issue by following the steps below:
  • Drag the message "Main mail.msg" from Outlook to the DragDrop application.
  • Read this "Main mail.msg" using following code:
static void EMAIL_451133()
{
MapiMessage mMapiMessage = MapiMessage.FromFile(@"D:\Aspose\Main mail.msg");
foreach (var attachment in mMapiMessage.Attachments)
{
attachment.Save(attachment.LongFileName);
MemoryStream content = new MemoryStream();
attachment.Save(content);
content.Position = 0;
writeFileToDisk(content, @"D:\Aspose\" + attachment.LongFileName);
}
}
static void writeFileToDisk(MemoryStream content, string fileName)
{
FileStream file = new FileStream(fileName, FileMode.Create, System.IO.FileAccess.Write);
byte[] bytes = new byte[content.Length];
content.Read(bytes, 0, (int)content.Length);
file.Write(bytes, 0, bytes.Length);
file.Close();
content.Close();
}

  • "Attachment Mail.msg" is saved on disc.
  • Press "Send To-> Mail Recipient" from the right click menu in windows explorer.
  • On my system Thunderbird is opened automatically where a new message is formatted and "Attachment Mail.msg" is attached as attachment by default.
  • My account credentials are used in the From field.
I have attached the snap shot of draft mail opened in Thunderbird.

Could you please repeat the steps above and let us know your feedback as I am still unable to re-produce the issue and everything is working fine at my end. I am using Windows 7, Outlook 2010, Thunderbird and VS 2010.

You reads the mail form file - this is not what I do. Read the message from a stream from Outlook! And also it’s attachments, yout should not save them to disk.

And I have Outlook as my mail client, not Thunderbird.

Hi,


We are sorry for the inconvenience caused to you.

Here a sample project is attached which is a drag and drop application. It allows to drag a message from Outlook and this dropped message in the stream is directly loaded into MapiMessage. Next it extracts attachment and saves it to the disc.

This saved attachment can be sent using “Send To -> Mail recipient” from explorer. This time I configured Outlook as my default mail client, therefore new draft mail is opened in Outlook.

Could you please explain the sentence below? If we don’t save attachment to the disc, how can we check windows explorer feature.
stasgisin3:
And also it’s attachments, you should not save them to disk.

If the attached project and explanation above does not resolve the issue, could you please send us some sample application which can be used to re-produce the issue here. Also please make it sure that you use latest assembly Aspose.Email for .NET 2.7.0 in your sample application.

We have a Client-Server architecture and because we transport the mails and attachments over the wire as streams, I don’t need to save files to disc and then read them again into stream. But it works now with the attachment’s Save() method to a stream and not to disc.

Hi,


Thanks for writing to support team again.

Could you please confirm whether your issue is resolved or not as I could not clearly understand from your previous post. If the issue is not resolved, please send us some sample application which can be used to re-produce the issue.


Yes, saving the attachment over its save method to a stream resolves the issue.

Hi,


It’s good to know that using the saving to stream method solved your issue. If you have any query/inquiry related to Aspose.Email, please feel free to contact us. We’ll be glad to assist you further.