Plain Text Emails Arrive Blank

EDN Admin

Well-known member
Joined
Aug 7, 2010
Messages
12,794
Location
In the Machine
I am using Visual Studio 2008 Pro to create a web application in Visual Basic. This app takes the information filled in by a user and then sends it to various people. Some of these people get the email in HTML, the rest in plain text. However, whenever I
use the code below to send the plain text email, when the email arrives in my Outlook 2010 Inbox it is completely blank. If I leave the code alone and change only .IsBodyHTML from False to True, it works (it sends the email formatted for HTML).
<pre class="prettyprint lang-vb Dim objEmail As New MailMessage()
Dim objMailserver As New SmtpClient("192.168.7.1")
Dim strBody As String

objEmail.IsBodyHtml = False
objEmail.From = New MailAddress(Session("RUserEmail"), Session("RUserName"))
objEmail.To.Add(New MailAddress("nick.marinelli@lgbs.com"))
objEmail.Subject = "Account Removal Request"
strBody = "Please disable the account for the following employee:" & vbCrLf & vbCrLf
strBody = strBody & "Effective Date: " & Session("EffectiveDate").ToString & vbCrLf
strBody = strBody & "Effective Time: " & Session("EffectiveTime").ToString & vbCrLf
strBody = strBody & "First Name: " & Session("EmpFName").ToString & vbCrLf
strBody = strBody & "Last Name: " & Session("EmpLName").ToString & vbCrLf
strBody = strBody & "Office: " & Session("EmpOffice").ToString & vbCrLf
strBody = strBody & "Email: " & Session("EmpEmail").ToString & vbCrLf
strBody = strBody & "Manager: " & Session("EmpManager").ToString & vbCrLf
strBody = strBody & "Employee Number: " & Session("EmpNum").ToString & vbCrLf
strBody = strBody & "Comments/Special Instructions: " & Session("Comments").ToString & vbCrLf & vbCrLf
strBody = strBody & "Requesting User: " & Session("RUserName").ToString & vbCrLf
objEmail.Body = strBody
Try
objMailserver.Send(objEmail)
Catch ex As Exception

End Try[/code]
Also, if I create an entirely new web app, using only this code, it sends the email correctly as plain text.<br/>
Please Help!
<
Nick Marinelli Linebarger Goggan Blair & Sampson, LLP
<br/>

View the full article
 
Back
Top