+1 vote

hello. how do I copy text from an email? for example, there is a letter called "ERROR", AND it is written in the text "HELLO, BUDDY". how to make the program copy this "HELLO, BUDDY" and in the near future it could insert it somewhere?


I apologize for the incomplete question, I use c # and IMAP, now I will try to explain more specifically. there is text output by imap client, this text is a message (message content). I want the program to be able to copy this text. I'm sorry, for an incomprehensible questionХ

by (1.4k points)
Please edit your question to more specific. What programming language are you using? Are you using IMAP or POP3? What exactly do you mean by coping?

1 Answer

+1 vote
 
Best answer

If you are talking about this sample:

using(Imap imap = new Imap())
{
    imap.Connect("imap.server.com");  // or ConnectSSL for SSL
    imap.UseBestLogin("user", "password");
    imap.SelectInbox();
    List<long> uids = imap.Search(Flag.Unseen);
    foreach (long uid in uids)
    {
        IMail email = new MailBuilder()
            .CreateFromEml(imap.GetMessageByUID(uid));
        Console.WriteLine(email.Subject);
    }
    imap.Close();

}

... and this line specifically:

Console.WriteLine(email.Subject);

you can simply create a local variable:

string subject = email.Subject;

To access email body you can use following properties/methods:

  • IMail.Text - gets plain text version of this email message.
  • IMail.Html - gets HTML version of this email message.
  • IMail.GetBodyAsText() - returns body in plain text format. Performs email HTML/RTF to text conversions when needed.
  • IMail.GetBodyAsHtml() - returns body in HTML format. Performs email text to HTML conversions when needed.
by (269k points)
selected by
...