How to send an HTML file via VB.NET
Posted on 2010-11-29
I have seen a number of examples of how to construct a simple HTML message body when sending an e-mail via VB.NET. If the intended message is constructed elsewhere and saved as an HTML file, how can I send the file contents as the message body?
What I have thus far is:
Dim credential As New System.Net.NetworkCredential("firstname.lastname@example.org", "mypw")
Dim client As New SmtpClient()
client.Host = "smtp.mysite.com"
client.Credentials = credential
Dim email As New MailMessage
email.From = New MailAddress("MyFrom@FromEmail.com")
email.Subject = "My Subject"
email.IsBodyHtml = True
email.DeliveryNotificationOptions = DeliveryNotificationOptions.OnFailure
StrMailBody = <I need to specify an HTML file string here>
email.Body = StrMailBody
The code works fine with a simple text entry for email.body, but I need to figure out how to send the contents of an HTML file.