0 votes
by (260 points)
edited

Hi

I am using your Rebex Mail and have some problems creating an alternateview and add it to the message. The htmlbody is simple html and comes from a richedit-control. When i try this by using Net.Mail objects its working fine:

Dim view As Net.Mail.AlternateView = Net.Mail.AlternateView.CreateAlternateViewFromString(htmlBody, Encoding.UTF8, MediaTypeNames.Text.Html)

The Rebex.Mail.AlternateView does not have an "CreateAlternateViewFromString"-method so i try it this way:

Dim view As New Rebex.Mail.AlternateView(htmlBody, MediaTypeNames.Text.Html)

but always get an error, something like "illegal char found in the path".

Maybe the missing encoding-info is the problem? Would be nice if someone has an idea about this.

Thanks, Timo

Applies to: Rebex Secure Mail

1 Answer

+1 vote
by (73.5k points)
edited
 
Best answer

Please note the arguments of the AlternateView constructor. It is only a fileName or contentStream, not contentString itself. To create AlternateView from string you can use following code:

Dim ms As New MemoryStream(Encoding.UTF8.GetBytes(htmlBody))
Dim view As New Rebex.Mail.AlternateView(ms, MediaTypeNames.Text.Html)
by (260 points)
edited

Hi Lukas, thanks for that! Thought it was too late at night for coding this part ...

...