0 votes

Hello,

I am using Mail.dll for email operations. I want to set functionality on the base of Format of the email message.
Example. If email message is simple(not formated, no table, no image) text messagem, I want to wrap the text in Container.

How can I identify the message has simple text?

by (3.0k points)

1 Answer

0 votes

You can use IMail.IsText, IMail.IsHtml and IMail.IsRtf to check, in which formats (plain text/HTML/RTF) email message body is specified.

by (301k points)
Can you please suggest me in following code?
Limilabs.Client.IMAP.Imap imapSetting;
//set imapSetting details
var mailInfos = imapSetting.GetMessageInfoByUID(allnewMessageID);
foreach (MessageInfo msgInfo in mailInfos.OrderByDescending(t => t.UID))
{
    //get info from msgInfo of type MessageInfo
}

There is no method like IsText in MessageInfo class.
Use MessageInfo.BodyStructure.Text, MessageInfo.BodyStructure.Html, MessageInfo.BodyStructure.Rtf. Check if they are null or not.
Thank you.
I have tried with sending 4 emails. 3 text mail and 1 text mail with image.
In all the cases, MessageInfo.BodyStructure.Text != null         MessageInfo.BodyStructure.Html != null
In all case, MessageInfo.BodyStructure.rtf == null         

It is not easy to identify.
Can you please tell me what kind of mail will be consider as Text one?
Those that have text/plain part defined.
Can you please give me simple example of both? So, I can identify accordingly and pass the result to user.
Email either has text/plain part or it doesn't. I'm not sure what is your problem exactly?

1.
Subject: text only
Content-type: text/plain

body

2.
Subject: html only
Content-type: text/html

<strong>body</strong>
I have following requirement.
I have to categorize mail in 2 types. 1- Plain Text Mail
2- Formatted Text Mail.

1- Plain Text Mail: Mails which have only text-plain text details. No image, no table etc in message body
2- Formatted Text Mail: Mails which can have anything. Like image, tables etc

I have C#.net application. I use MessageInfo.
I have describe requirement above. Can you please suggest me easiest way?
As I already said. Use MessageInfo.BodyStructure.Text, MessageInfo.BodyStructure.Html, MessageInfo.BodyStructure.Rtf. Check if they are null or not. Text only message has only Text property set.
I am sorry but I am not getting exactly what you want to say.

if mail is plain text:
     MessageInfo.BodyStructure.Text is NOT NULL
     MessageInfo.BodyStructure.Html is NULL

if mail is html:
     MessageInfo.BodyStructure.Html is NOT NULL
     MessageInfo.BodyStructure.Text is NULL     

Am I getting right?
No, MessageInfo.BodyStructure.Text may be not null for HTML emails. Such message have 2 body versions: text/plain and text/html.
...