Spire.Email for .NET is a professional .NET Email library specially designed for developers to create, read and manipulate emails from any .NET (C#, VB.NET, ASP.NET) platform with fast and high quality performance.

Fri Jan 29, 2021 6:25 pm

Hi,

I am trying to retrieve .msg file as an attachment from IMAP email using Spire.dll. I have the latest version of the spire DLL.

After using 'Attachment' class, the attachment.Filename returns empty string for .msg attachment file.

Does Spire.dll support .msg file as an email attachment? If yes then why 'Attachment' class doesn't work as it works for other file types?

Please let me know. You support is appreciated.

Thanks,

a_shinde
 
Posts: 14
Joined: Thu Sep 24, 2020 8:04 pm

Mon Feb 01, 2021 2:22 am

Hello,

Thanks for your inquiry and sorry for the late reply as weekend.

Our Spire.Email supports .msg file as an email attachment. Please refer to the following code to get the filename of .msg attachment file.
Code: Select all
 message.Attachments[0].ContentType.Name;

If the issue still exists, please provide us with your message file for further investigation.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon Feb 01, 2021 3:50 pm

Hi Marcia,

Thank you for the response. If I use ContentType.FileName, I get filename as 'ATT00001.rfc822'. I am looking for the subject line of .msg attachment as a file name.

I am using 3.9.1 version of Spire.Email DLL. Can you please advise?

Thanks,

a_shinde
 
Posts: 14
Joined: Thu Sep 24, 2020 8:04 pm

Tue Feb 02, 2021 10:50 am

Hi,

Thanks for your feedback.
Do you want to get the name value likes ATT00001.msg by ContentType.Name?

Sincerely,
Amy
E-iceblue support team
User avatar

amy.zhao
 
Posts: 2774
Joined: Wed Jun 27, 2012 8:50 am

Tue Feb 02, 2021 6:51 pm

Yes, ATT00001.msg is fine. As long as file name is unique for each .msg attachment that should be fine.

a_shinde
 
Posts: 14
Joined: Thu Sep 24, 2020 8:04 pm

Wed Feb 03, 2021 9:23 am

Hello,

Thanks for your feedback!

I created an email message with .msg file as an attachment and tested it with the latest Spire.Email v4.1.2, but did not reproduce your issue. The value of ContentType.Name is correct. Here I uploaded the result screenshot for your reference, and below is my test code.

If your testing code is different from mine, please provide it and your testing files to help us further investigate . You can send it to us via email (support@e-iceblue.com).

Thanks in advance.

Code: Select all
            ImapClient imapClient = new ImapClient();

            //Set host, username, password etc. for the client
            imapClient.Host = "outlook.office365.com";
            imapClient.Username = username;
            imapClient.Password = password;
            imapClient.Port = 143;
            imapClient.ConnectionProtocols = ConnectionProtocols.Ssl;

            //Connect to the server
            imapClient.Connect();

            //get imap message and save it
            imapClient.Select("Inbox");
            MailMessage message = imapClient.GetFullMessage(1);
            message.Save(message.Subject + ".msg", MailMessageFormat.Msg);

            //create new message
            MailAddress addressFrom = username;
            MailAddress addressTo = receivename;
            MailMessage newmessage = new MailMessage(addressFrom, addressTo);
            newmessage.Subject = "Have a Nice Holiday";
            newmessage.BodyText = "Have a Nice Holiday!!!!";
            newmessage.Date = DateTime.Now;

            //add attachment
            newmessage.Attachments.Add(new Attachment(message.Subject + ".msg"));

            //get name of attachment
            string filename = newmessage.Attachments[0].ContentType.Name;

getFileName.png


Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Mon Feb 08, 2021 1:39 am

Hello,

Hope you are doing well!

How is the issue now? If it still exists, could you please provide your testing code and files to us for further investigation? You can send it to us via email (support@e-iceblue.com).

Thanks in advance.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Wed Feb 24, 2021 6:05 pm

Hi Marcia,

You may close the support issue for now. I didn't get chance to test the solution you have provided. If I have any questions/issue, will update the ticket but for now you may close it.

Thanks

a_shinde
 
Posts: 14
Joined: Thu Sep 24, 2020 8:04 pm

Thu Feb 25, 2021 1:09 am

Hello,

Thanks for your feedback!

If you encounter any issues related to our product in the future, just feel free to contact us.

Have a nice day!

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Thu Apr 29, 2021 9:15 pm

Hi Marcia,

Can you please send a working example of spire .net being used to fetch .msg file as an attachment?

Appreciate your support.

Thanks

a_shinde
 
Posts: 14
Joined: Thu Sep 24, 2020 8:04 pm

Fri Apr 30, 2021 1:29 am

Hello,

Thanks for your inquiry!

Of course, please refer to the following attachment to fetch .msg file as an attachment.
SpireEmailSample.zip

If there are any issues during the test, please feel free to contact us.

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Fri Apr 30, 2021 2:35 pm

Hi Marcia,

I think I framed my question incorrectly.

I have an IMAP outlook message say "message1" and there is a .msg file attachment say "message2" inside "message1". I would like to retrieve "message2" file as an .msg attachment and open it to read its subject, email body etc.

The example you have sent is for sending an email with .msg file as an attachment. I want exact opposite behavior i.e. receive a message with .msg attachment file and extract .msg as an attachment.

a_shinde
 
Posts: 14
Joined: Thu Sep 24, 2020 8:04 pm

Mon May 03, 2021 12:28 pm

Hello,

Thanks for your response.
Attached is the modified project for your reference. If you have further questions, just feel free to contact us.

Sincerely,
Rachel
E-iceblue support team
User avatar

rachel.lei
 
Posts: 1571
Joined: Tue Jul 09, 2019 2:22 am

Thu May 13, 2021 3:55 pm

I tried the example given. When I try following code I get filePath value as "ATT00001.rfc822" and not ".msg"

string filePath = emailAttachment.ContentType.Name;

Do I need to get a latest version of spire.email dll? I am using 3.9.1.12046.

a_shinde
 
Posts: 14
Joined: Thu Sep 24, 2020 8:04 pm

Fri May 14, 2021 6:44 am

Hello,

Thanks for your feedback!

Yes, you can try again with our latest Spire.Email Version:4.1 to verify whether the result file path is correct. If the issue still exists, please refer to the following points to provide us with the file so that we can investigate your issue faster and efficiently.

1. If you were getting a message with attachment from the network, please provide us with the msg file which you get the wrong file path, you can save it by file->save as->save to computer.
2. If you are loading a local msg file, please provide us with your msg file which contains msg attachments for reference.

Besides, please provide us with the following information at the same time:
1. Your target framework (E.g. .Net framework 4.6.1)
2. Your system information (E.g. Win7, 64 bit)
3. Your region setting (E.g. China, Chinese)

All in all, our Spire.Email reads the name of the attachment according to the specific file, and this error you encountered is mostly related to the data in the file, your file is very important for us to investigate your issue. To protect your privacy, you can send them to us via email (support@e-iceblue.com).

Hope you can understand and look forward to your reply!

Sincerely,
Marcia
E-iceblue support team
User avatar

Marcia.Zhou
 
Posts: 858
Joined: Wed Nov 04, 2020 2:29 am

Return to Spire.Email