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.
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.
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);
}
- Drag the message "Main mail.msg" from Outlook to the DragDrop application.
- Read this "Main mail.msg" using following code:
{
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.
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,
stasgisin3:And also it’s attachments, you should not save them to disk.
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,
Yes, saving the attachment over its save method to a stream resolves the issue.
Hi,