Click here to Skip to main content
15,885,985 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I am not getting how to convert body text into normal string.
I already did seperated out, but how to get body text from it i am not getting, bodytext is using content transfer encoding "7 bit".

Does any body knows regarding this?

What I have tried:

var myattachments = new List<MimePart>();
     var multiparts = new List<Multipart>();  from received mail.
<pre>  using (var iter = new MimeIterator(email))
                        {
                            
                            while (iter.MoveNext())
                            {
                                var multipart = iter.Parent as Multipart;
                                var part = iter.Current as MimePart;

                                if (multipart != null && part != null && part.IsAttachment)
                                {
                              
                                    multiparts.Add(multipart);
                                    myattachments.Add(part);
                                }
                            }
                        }

                      
                        for (int i = 0; i < myattachments.Count; i++)
                            multiparts[i].Remove(myattachments[i]);
Posted
Updated 4-Nov-20 0:07am
Comments
Richard Deeming 4-Nov-20 5:29am    
Which library are you using to parse the message? This sort of thing should be fairly simple with MimeKit[^].
piyush_pimple 4-Nov-20 6:01am    
Hi, Yes I am using mimekit.
but the mail is "multipart" type. and mail body is encoded by 7 bit
piyush_pimple 4-Nov-20 23:42pm    
https://postimg.cc/gallery/WD9nRBG
i added my code screen-shots here

1 solution

See this solution from the author of the MimeKit library:
There are multiple ways to get the message body:
  • Traversing the MIME tree manually ... (Difficulty: Extreme)
  • Using a MimeIterator ... (Difficulty: Extreme)
  • Using a MimeVisitor subclass to traverse the MIME tree structure ... (Difficulty: Moderate)
  • ... use the MimeMessage.TextBody and/or MimeMessage.HtmlBody properties. (Difficulty: Easy Mode)
 
Share this answer
 
Comments
piyush_pimple 4-Nov-20 21:12pm    
Hi Thank You for reply.
but i want to display that MailBody text into textarea on my page, but that bodytext is in some different format.
So is there any way so that i can text text only?
here are my screen shots of code
https://postimg.cc/gallery/WD9nRBG
Richard Deeming 5-Nov-20 4:29am    
What do the HtmlBody and TextBody properties return?

Your screenshot is looking at the Body property, which represents a tree of content parsed from the MIME message, and isn't trivial to handle.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900