Author |
|
Amelia Newbie
Joined: 17 May 2021
Online Status: Offline Posts: 4
|
Posted: 17 May 2021 at 3:33am | IP Logged
|
|
|
Hi,
I am looking to get some guidance or direction on an issue I am having with MailBee.NET v12.2.0.630 please.
I am uploading an email (.msg) with an attachment file (also .msg) to SharePoint online having used the MailMessageToMsg function. The email loads fine into SharePoint, however when I open the attachment the body is empty.
When I upload a msg file with a msg attachment directly to SharePoint online then this works as expected and I can see the whole email message in the attachment.
Has anyone come across this issue before?
Thanks
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 17 May 2021 at 4:04am | IP Logged
|
|
|
Hi,
If you open the generated .msg with Outlook, is this attachment ok? I.e. is the issue specific to SharePoint only?
Regards,
Alex
|
Back to Top |
|
|
Amelia Newbie
Joined: 17 May 2021
Online Status: Offline Posts: 4
|
Posted: 17 May 2021 at 5:39am | IP Logged
|
|
|
Hi Alex,
The issue is not specific to SharePoint - I have also been able to replicate the issue in a small standalone project. When I open the resulting .msg file with Outlook, the attachment is blank.
Sample code as follows:
MailBee.Mime.MailMessage msg = new MailBee.Mime.MailMessage
{
BodyHtmlText = "Test email body content"
};
string path = @"..\..\Sample Attachments\EmailAttachment.msg";
byte[] attachmentBytes = File.ReadAllBytes(path);
if (attachmentBytes != null)
{
msg.Attachments.Add(attachmentBytes, "Email Attachment.msg", "", null, null,
MailBee.Mime.NewAttachmentOptions.None, MailBee.Mime.MailTransferEncoding.None);
}
//Converter
MsgConvert messageConverter = new MsgConvert("####")
{
MsgAsUnicode = true,
HtmlToRtfMethod = HtmlToRtfConversionMethod.None,
MsgAsDraft = false
};
using (MemoryStream emailMemoryStream = new MemoryStream())
{
messageConverter.MailMessageToMsg(msg, emailMemoryStream);
if (emailMemoryStream.Length != 0)
{
using (FileStream outputStream =
File.Create(@"..\..\OutputEmails\EmailWithAttachment.msg"))
{
emailMemoryStream.WriteTo(outputStream);
}
}
}
Please can you advise?
|
Back to Top |
|
|
Alex AfterLogic Support
Joined: 19 November 2003
Online Status: Offline Posts: 2206
|
Posted: 17 May 2021 at 10:02am | IP Logged
|
|
|
Hi,
I'd try something simpler:
Code:
conv = new MsgConvert();
msg.Subject = "outer subject";
msg.BodyPlainText = "outer body";
msg.Attachments.Add(@"c:\Temp\inner.msg");
conv.MailMessageToMsg(msg, @"C:\Temp\outer.msg");
|
|
|
For me, this works, inner email opens just fine. If it works for you, you can then gradually adjust the sample to match your original code (although I'm not sure if it's really needed, such as separately reading the attachment's content and feed it to MailBee rather than letting MailBee do both operations in the first place).
Regards,
Alex
|
Back to Top |
|
|
Amelia Newbie
Joined: 17 May 2021
Online Status: Offline Posts: 4
|
Posted: 18 May 2021 at 12:43am | IP Logged
|
|
|
Hi Alex
Unfortunately the code you suggested does not work for me and I am still getting blank attachments.
Are there any requirements for the inner email that we should be aware of that might be stopping the body being processed correctly?
|
Back to Top |
|
|
Igor AfterLogic Support
Joined: 24 June 2008 Location: United States
Online Status: Offline Posts: 6104
|
Posted: 18 May 2021 at 12:58am | IP Logged
|
|
|
Hello,
Would it be possible to provide us with .MSG file you're trying to attach? You can send us the file via HelpDesk. Thank you.
--
Regards,
Igor, Afterlogic Support
|
Back to Top |
|
|
Amelia Newbie
Joined: 17 May 2021
Online Status: Offline Posts: 4
|
Posted: 18 May 2021 at 1:11am | IP Logged
|
|
|
Thanks Igor, I will send the file via Helpdesk.
|
Back to Top |
|
|