erdomke / RtfPipe

Library for processing rich-text format (RTF) streams
MIT License
121 stars 44 forks source link

RtfPipe.Rtf.ToHtml(RichTextBox1.Rtf) doesn't work with .net MailMessage #44

Closed JosephNC-GitHub closed 3 years ago

JosephNC-GitHub commented 4 years ago

Hello, I'm working to use a richtextbox to format an html email and send it using .net mailmessage but the received message does not look like the richtextbox layout. Text sends fine but images do not. Here's my code:

Dim MessageHTML As String = RtfPipe.Rtf.ToHtml(RichTextBox1.Rtf)

Dim Client As New SmtpClient() Dim SSL As Boolean = False Dim Port As String = "25" Dim MailServ As String = "smtp.sdafdfa.net" Dim Message As New MailMessage(to, from) With { .Subject = RichTextBox3.Text, .IsBodyHtml = True, .Body = MessageHTML } Dim basicAuthenticationInfo As New System.Net.NetworkCredential(user, pass) Client.Host = MailServ Client.UseDefaultCredentials = False Client.Credentials = basicAuthenticationInfo Client.EnableSsl = SSL Client.Port = Port Client.Send(Message) Message.Dispose()

Any idea what could be wrong?

Thanks for your help!

erdomke commented 3 years ago

Without knowing more about the RTF you are trying to send, it is hard to say. If memory serves, many e-mail clients might not do well with the data URIs that RtfPipe uses by default. You might need to use the callback ImageUriGetter callback to save the image as an attachment instead and reference the cid of the attachment instead.