Search The ForumSearch   RegisterRegister  LoginLogin

MailBee.NET Objects

 AfterLogic Forum : MailBee.NET Objects
Subject Topic: Empty body of attached .msg Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
Amelia
Newbie
Newbie


Joined: 17 May 2021
Online Status: Offline
Posts: 4
Posted: 17 May 2021 at 3:33am | IP Logged Quote Amelia

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 View Amelia's Profile Search for other posts by Amelia
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 17 May 2021 at 4:04am | IP Logged Quote Alex

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 View Alex's Profile Search for other posts by Alex
 
Amelia
Newbie
Newbie


Joined: 17 May 2021
Online Status: Offline
Posts: 4
Posted: 17 May 2021 at 5:39am | IP Logged Quote Amelia

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 View Amelia's Profile Search for other posts by Amelia
 
Alex
AfterLogic Support
AfterLogic Support
Avatar

Joined: 19 November 2003
Online Status: Offline
Posts: 2206
Posted: 17 May 2021 at 10:02am | IP Logged Quote Alex

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 View Alex's Profile Search for other posts by Alex
 
Amelia
Newbie
Newbie


Joined: 17 May 2021
Online Status: Offline
Posts: 4
Posted: 18 May 2021 at 12:43am | IP Logged Quote Amelia

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 View Amelia's Profile Search for other posts by Amelia
 
Igor
AfterLogic Support
AfterLogic Support


Joined: 24 June 2008
Location: United States
Online Status: Offline
Posts: 6038
Posted: 18 May 2021 at 12:58am | IP Logged Quote Igor

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 View Igor's Profile Search for other posts by Igor
 
Amelia
Newbie
Newbie


Joined: 17 May 2021
Online Status: Offline
Posts: 4
Posted: 18 May 2021 at 1:11am | IP Logged Quote Amelia

Thanks Igor, I will send the file via Helpdesk.
Back to Top View Amelia's Profile Search for other posts by Amelia
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump

Powered by Web Wiz Forums version 7.9
Copyright ©2001-2004 Web Wiz Guide