'How to send HTML or plain text message via Mimekit

I'm trying to send an HTML message with my font and size but it doesn't work.

If I'm not mistaken, I have to convert the text in my richTextBox from RTF to HTML to be able to do that, I think my problem is there.

My code gives this:

                    BodyBuilder builder = new BodyBuilder();
                    MimeMessage mime = new MimeMessage();
                    if(checkBox1.Checked)
                    {
                        
                        builder.HtmlBody = richTextBox1.Rtf;
                    }
                    else
                    {
                        builder.TextBody = richTextBox1.Text;
                    }
                    
                    mime.Body = builder.ToMessageBody();


    private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
    {
         richTextBox1.Font = new Font(comboBox1.Text, richTextBox1.Font.Size);
         
    }
    private void comboBox2_SelectedIndexChanged(object sender, EventArgs e)
    {
        richTextBox1.Font = new Font(richTextBox1.Font.FontFamily, float.Parse(comboBox2.SelectedItem.ToString()));
        
    }

Thanks for your help please



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source