0 votes
by (120 points)
edited

Could you please help me? What is the best way to convert Rebex.Mail.MailMessage To System.Net.Mail.MailMessage. I do not whant to save file.

Applies to: Rebex Secure Mail
by (58.9k points)
edited

What do you need to acomplish with the System.Net.Mail.MailMessage? Do you want to send it via System.Net.Mail.SmtpClient or for something else? The best solution depends on the purpose.

by (120 points)
edited

I would like to save it in my DB. The other application has to use it later.

by (148k points)
edited

How do you save an instance of System.Net.Mail.MailMessage into a database? As far as I know, it can either be sent through an SMTP server or saved into a spool directory. Is there anything I missed?

I'm asking because even though Rebex.Mail.MailMessage can't be easily converted into System.Net.Mail.MailMessage (the System MailMessage doesn't have Load method), it might be possible to save it into a DB the same way.

By the way, you can convert Rebex.Mail.MailMessage into a byte array using its ToByteArray method and save that into a database. Later, pass the byte array to Load method.

by (120 points)
edited

To convert email in byte array or to serialize it. It's not a big deal. This mean that it's not a problem to save it in DB. The problem maybe later when third party program would like to use this object. I have Robex dll (and in general I like to use it) but they do not have it. This mean that I have to use one of the standard object. If you have any ideas, please let me know. Thank you for your time.

by (148k points)
edited

Actually, the result of both Rebex MailMessage.Save and .ToByteArray is a representation of the message in MIME format, which is well-defined and widely supported. Almost any email client can read it (Outlook 2010, Outlook Express, Windows Mail, Mozilla Thunderbird, etc.) and third-party mail components can read it (use .eml extension).

The only problem is with System MailMessage, which doesn't have Load or Save methods (actually, Save can be simulated by 'sending' it to a specified pickup folder, but you can't load the result back into System MailMessage), so its usefulness is very limited.

1 Answer

0 votes
by (148k points)

Rebex.Mail.MailMessage can't be easily converted into System.Net.Mail.MailMessage because System MailMessage doesn't have Load method. See the comments above for suggested solutions.

...