Value of type 'System.Net.Mail.MailMessage' cannot be converted to 'System.Net.Mail.AlternateView'

Trying to create an alternateview to send a txt email with the html formatted email.  I've used string builder to create the whole email, but I get this error.  Any ideas why?  i've bolded the line that throws the error...

Dim EmailBodyTxt As New StringBuilder

EmailBodyTxt.Append("<html><style type='text/css'>.table{border:solid; border-color:#006666; width:600;} ")
EmailBodyTxt.Append("<body><table class='table'><tr><td colspan='2'><h1>Test<br />RESPONSE SYSTEM</h1></td></tr> ")
EmailBodyTxt.Append("<tr><td>&nbsp;</td></tr> ")
TestEmail.Body = EmailBodyTxt.ToString


Never make important decisions on a Monday!
12/29/2008 9:14:53 PM 91979 articles. 4 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 21
Get it on Google Play
Get it on Apple App Store

It looks like you can't add a MailMessage, you have to pass something that has the type AlternateView. So create an AlternateView instead of a MailMessage.

Jef Claes

Visit my blog
12/29/2008 9:33:08 PM

Similar Artilces:

System.Net.Mail is giving error CS0029: Cannot implicitly convert type 'string' to 'System.Net.Mail.MailAddress'
I'm getting an error while trying to use the wizard to create a form and than pass it the vaibles to Mail. Any help would be much appreciated. SmtpClient smtpClient = new SmtpClient(); MailMessage message = new MailMessage(); try {   message.From = txtEmail.Text; message.To.Add(""); message.Subject = "Feedback"; message.CC.Add(""); message.CC.Add(""); message.IsBodyHtml = false; message.Body = txtMessage.Text; smtpClient.Send(message); lblStatus.Text = "Email successfully sent."; } catch (Exception ex) { lbl...

Value of type 'String' cannot be converted to 'System.Net.Mail.MailAddress'
My code is below:Protected Sub btnSendMsg_OnClick(ByVal Source As Object, ByVal E As EventArgs) Dim myMessage As New System.Net.Mail.MailMessage Dim myAttachment As System.Net.Mail.Attachment Dim myMail As System.Net.Mail.SmtpClient If Page.IsValid() Then myMessage.From = txtFromEmail.Text myMessage.To = txtToEmail.TextWhat can I do to fix this? MailMessage.To represents a collection that you Add addresses to.Dim recipient As MailAddress= new MailAddress(txtToEmail.Text) myMessage.To.Add(recipient)    Mike Banavige~~~~~~~~~~...

BC30002: Type 'System.Net.Mail.MailMessage' is not defined
<%@ Page Language="VB" Debug="true"%><%@ Import Namespace = "" %><%@ Import Namespace="system.web.mail" %><%@ Import Namespace="system.Net.mail" %> Dim msg As New System.Net.Mail.MailMessage        Dim smtp As New System.Net.Mail.SmtpClient                With msg            .From = New System.Net.Mail.MailAddress("from address")  ...

Cannot convert value of parameter 'Course_FK' from 'System.String' to 'System.Guid'
Hi, I'm building a site and I've been trying to accomplish something similar to what is talked about in "Working with Data in ASP.NET 2.0 :: Declarative Parameters" tutorial. Below is the code for my methods from the xsd. I tried to attach a screenshot of my xsd but for some reason I'm not allowed GetAllCourseNames() SELECT        CourseID, NameFROM            Course GetCourseScheduleByCourseID SELECT        ScheduleID, Course_FK, Date, TeeTime, NumberOfPlayersF...

Error: Value of type 'System.Data.CommandBehavior' cannot be converted to 'System.IAsyncResult'.
  I wrote this code to retrieve data from the database using autocomplete extender control. Dim Dr As SqlDataReaderDim RtData As List(Of String) = New List(Of String) Dr = MysqlCmd.EndExecuteReader(Data.CommandBehavior.CloseConnection) While Dr.Read()RtData.Add(Dr("CustName").ToString()) End While   Plz Help!   regards   yamani     The EndExecuteReader does not take a CommandBehavior.  The BeginExecuteReader does.  Please follow the example on the MSDN documentation:

Object of type 'System.DBNull' cannot be converted to type 'System.DateTime'.
Hi, How can I pass null values to a system.datetime? Thanks in advance for the help J   Below is my code:   Public Class Courses     Public Sub Update_Class(ByVal ClassId As Integer, _    ByVal StatusId As Integer, _    ByVal ClassNumber As Integer, _    ByVal TeacherId As Integer, _    ByVal AmountofParticipants As Integer, _    ByVal CourseDate1 As DateTime, _    ByVal CourseDate2 As DateTime, _    ByVal CourseDate3 As DateTime)     Dim myConnection As New SqlConnection(Conn...

Object of type 'System.Boolean' cannot be converted to type 'System.Int16'.
I have a Checkbox on a detailsview bound to a small int field in my database table.It binds fine when showing the item template on the detailsview, but when I try do an insert/update it blows up with that error.Surely I can bind a checkbox to an integer field, so that unchecked translates to 0, and checked translates to 1?The reason I use a smallint, is its future-proof.  If we decided to switch to a status instead off/on in the future, there are less changes required.  As long as 0 is False and any other value is considered True you should be able to bind the value like this: C...

Convert 'System.DBNull' to type 'System.String' ?
I have a textbox on my site that I want to populate with some data, however when the value is null, which is quite often.The problem is that when I call a static method which returns a string; when that string is DBNull, I get the following error which is absolutely correct.Unable to cast object of type 'System.DBNull' to type 'System.String'.So, what should I do to be able to ignore that the string is null and just display a "" string in the texbox?The code is as follows:    private void GetCartSmall(string sSessionID)    {      &n...

Value of type 'System.Web.UI.Control' cannot be converted to 'System.Web.SiteMap'.
 Hello,         I receive this error "System.Web.UI.Control' cannot be converted to 'System.Web.SiteMap" when I try to find the Sitemap control.  ...            <asp:SiteMapDataSource ID="SiteMapDataSource1" runat="server" />            <asp:ListView ID="ListView1" runat="server">            <LayoutTemplate>    ...

Value of type '1-dimensional array of System.Object' cannot be converted to 'System.Collections.ArrayList'
I am getting this error Value of type '1-dimensional array of System.Object' cannot be converted to 'System.Collections.ArrayList'. I am implementing something similar to what is in starter kits. I have a getRoles() function that fetches a two dimensional array. AccessLevel and Region. I have to check the status of the user on every page to display data based on their AccessLevel and Region they belong to. I am trying to read these values from the ArrayList but it is giving me the above error.. Anybody knows what I may be doing wrong.. Thanks in advance Can you please show the ...

Object of type 'System.DBNull' cannot be converted to type 'System.String' from formview
I have a formview that I am using for input to my datatable.  I am using an objectdatasource that uses a BLL.  This in turn points to my XSD tableadapter. When I test, and only fill in the required fields, I am getting the error Object of type 'System.DBNull' cannot be converted to type 'System.String' I am not sure what field is having the issue.  In my BLL for the Add, I have checked the dates for null and placed the value of DateTime.MinValue.  For the text fields, I have place "" if they are null.  Is this error being create prior to...

Value of type 'System.Array' cannot be converted to 'Integer'
 Hi,I have a C# code sample that I ran through a C#-to-VB converter, and now Visual Studio gives me the following error for Line 3 of the VB code (Line 6 of the C# code) below:Value of type 'System.Array' cannot be converted to 'Integer'I'm new to VB and C# and could not figure out how to correct this. How can I modify the VB code so that it doesn't give this error? --------------------------- Original Sample ------------------------------- 1 public static class DataSources2 {3 public static StatusCode[] GetHttpStatusCodes()4 ...

'fields' is not a member of 'System.Web.Mail.MailMessage'
I just installed DNN and tried to add a module, however this is happening in \components\Globals.vb. Any ideas? Thanks!htt:// the 'fields' property is supported only in version 1.1 of the .NET Framework, so it looks like you're using .net 1.0. You can download the 1.1 version from Cathal...

Name: haznen Email: haznenatyahoodotcom Product: Gran Paradiso Alpha 8 Summary: '''''''''''''''''''' Comments: '''''''''''''''''''''''''''''''''''' Browser Details: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9a1) Gecko/20061204 UGES/ GranParadiso/3.0a1 From URL: Note to readers: Hendrix gives...

Web resources about - Value of type 'System.Net.Mail.MailMessage' cannot be converted to 'System.Net.Mail.AlternateView' -

Resources last updated: 12/7/2015 9:57:18 PM