Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 8451
  • Last Modified:

Asp.Net : class defined in this code file matches the 'inherits' attribute Error

Hello!

I am developing a page for sending an email asynchronously. I have the sendemail.aspx page with the codebehind page sendemail.aspx.cs.

I get the following error ONLY when I test (compile) on the production server:

ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl). (Complete Error Text Attached to this post.)

I have tried adding a namespace, different names, etc. but I can't get this to compile. It compiles in VS 2005.  What am I doing wrong? THANKS!!!!



<<<<<<<sendemail.aspx page>>>>>>>>>>>>>>
 
<%@ Page Language="C#" AutoEventWireup="true" Codefile="sendemail.aspx.cs" Inherits="sendemail" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Send Email to Prospective Canidate</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     <p>
      <asp:TextBox ID="txtSubject" runat="server" Columns="50" />
    </p>
    <p>
      <asp:TextBox ID="txtBody" runat="server" TextMode="MultiLine" Rows="5" Columns="60" />
    </p>
    <p>
      <asp:Button ID="btnSend" runat="server" Text="Send Email" 
        onclick="btnSend_Click" /></p>
    <p>
      <asp:Label ID="labMessage" runat="server" /></p>
    </div>
    </form>
</body>
</html>
 
<<<<<<<sendemail.aspx.cs page>>>>>>>>>>>>>>
 
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Net.Mail;
 
 public partial class sendemail : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
        protected void btnSend_Click(object sender, EventArgs e)
        {
            SendMail();
        }
 
        /// <summary>
        /// Sends email asynchronously.
        /// </summary>
        private void SendMail()
        {
            System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
 
            mailMessage.From = new MailAddress("test@test.com");
            mailMessage.To.Add(new MailAddress("test@test.com"));
 
            mailMessage.Subject = txtSubject.Text.Trim();
            mailMessage.Body = txtBody.Text.Trim();
 
            SmtpClient smtpClient = new SmtpClient();
            Object userState = mailMessage;
 
            //Attach event handler for async callback
            smtpClient.SendCompleted += new SendCompletedEventHandler(smtpClient_SendCompleted);
 
            try
            {
                //Send the email asynchronously
                smtpClient.SendAsync(mailMessage, userState);
            }
            catch (SmtpException smtpEx)
            {
                //Error handling here
            }
            catch (Exception ex)
            {
                //Error handling here
            }
        }
 
        /// <summary>
        /// Event handler for processing completion information after asynchronous email sent.
        /// </summary>
        void smtpClient_SendCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
 
            //Get UserState as MailMessage instance from SendMail()
            MailMessage mailMessage = e.UserState as MailMessage;
 
            if (e.Cancelled)
            {
                labMessage.Text = "Sending of email message was cancelled. Address=" + mailMessage.To[0].Address;
            }
 
            if (e.Error != null)
            {
                labMessage.Text = "Error occured, info=" + e.Error.Message;
            }
            else
            {
                labMessage.Text = "Mail sent successfully";
            }
 
        }
    }

Open in new window

error.txt
0
Cyberzones
Asked:
Cyberzones
  • 5
  • 4
  • 3
1 Solution
 
sunithnairCommented:
Try this way
<<<<<<<sendemail.aspx page>>>>>>>>>>>>>>
 
<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="sendemail.aspx.cs" Inherits="sendemail" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Send Email to Prospective Canidate</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
     <p>
      <asp:TextBox ID="txtSubject" runat="server" Columns="50" />
    </p>
    <p>
      <asp:TextBox ID="txtBody" runat="server" TextMode="MultiLine" Rows="5" Columns="60" />
    </p>
    <p>
      <asp:Button ID="btnSend" runat="server" Text="Send Email" 
        onclick="btnSend_Click" /></p>
    <p>
      <asp:Label ID="labMessage" runat="server" /></p>
    </div>
    </form>
</body>
</html>
 
<<<<<<<sendemail.aspx.cs page>>>>>>>>>>>>>>
 
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
using System.Net.Mail;
 
 public partial class sendemail : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
 
        }
        protected void btnSend_Click(object sender, EventArgs e)
        {
            SendMail();
        }
 
        /// <summary>
        /// Sends email asynchronously.
        /// </summary>
        private void SendMail()
        {
            System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
 
            mailMessage.From = new MailAddress("test@test.com");
            mailMessage.To.Add(new MailAddress("test@test.com"));
 
            mailMessage.Subject = txtSubject.Text.Trim();
            mailMessage.Body = txtBody.Text.Trim();
 
            SmtpClient smtpClient = new SmtpClient();
            Object userState = mailMessage;
 
            //Attach event handler for async callback
            smtpClient.SendCompleted += new SendCompletedEventHandler(smtpClient_SendCompleted);
 
            try
            {
                //Send the email asynchronously
                smtpClient.SendAsync(mailMessage, userState);
            }
            catch (SmtpException smtpEx)
            {
                //Error handling here
            }
            catch (Exception ex)
            {
                //Error handling here
            }
        }
 
        /// <summary>
        /// Event handler for processing completion information after asynchronous email sent.
        /// </summary>
        void smtpClient_SendCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
        {
 
            //Get UserState as MailMessage instance from SendMail()
            MailMessage mailMessage = e.UserState as MailMessage;
 
            if (e.Cancelled)
            {
                labMessage.Text = "Sending of email message was cancelled. Address=" + mailMessage.To[0].Address;
            }
 
            if (e.Error != null)
            {
                labMessage.Text = "Error occured, info=" + e.Error.Message;
            }
            else
            {
                labMessage.Text = "Mail sent successfully";
            }
 
        }
    }

Open in new window

0
 
sunithnairCommented:
Change CodeFile in aspx page CodeBehind
0
 
CyberzonesAuthor Commented:
Hi Sunithnair,

Thanks for helping. Itried the change you mentioned above and I get this error:

Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.

Parser Error Message: Could not load type 'sendemail'.

Source Error:


Line 1:  <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="sendemail.aspx.cs" Inherits="sendemail" %>
Line 2:  
Line 3:  <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
 
0
What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

 
CB_ThirumalaiCommented:
Asp.Net 2.0 does not support CodeBehind="sendemail.aspx.cs" .  Use CodeFile="sendemail.aspx.cs" instead
0
 
CyberzonesAuthor Commented:
CodeFile="sendemail.aspx.cs" is what I had orignally.
0
 
CB_ThirumalaiCommented:
The error that you have attached, shows that you have the sendemail class in the namespace Jobs.  Try putting the Inherits as, Inherits="Jobs.sendemail".

> I have tried adding a namespace, different names, etc. but I can't get this to compile. It compiles in VS 2005.  What am I doing wrong?
Where have you tried adding the namespace to?  Can you once again try renaming the file as "SendEmailFromAjax", wherever necessary (Inherits, classname, add namespace, etc)?
0
 
CyberzonesAuthor Commented:
Ok, I triad it again and still no go.

I have attached the compiled error text message to this post.

Do I need to change anything in the web.config? I thought this would be a simple send email code to add to our site. Strange error.
error1.txt
0
 
CB_ThirumalaiCommented:
I think there is something to do with the namespace.  The file you have attached does not contain any error information.  Do you use any other namespace in your web app?
0
 
CyberzonesAuthor Commented:
Well, we probably do. It is on a Community Server application.

Here is more error info:

Compilation Error
Description: An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message: ASPNET: Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl).

Source Error:

 

Line 14: namespace Jobs
Line 15: {
Line 16:     public partial class sendemail : System.Web.UI.Page
Line 17:     {
Line 18:         protected void Page_Load(object sender, EventArgs e)
 

Source File: d:\domains\nuclearstreet.com\Jobs\sendemail.aspx.cs    Line: 16



Show Detailed Compiler Output:


c:\windows\system32\inetsrv> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" /t:library /utf8output /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\d19d6c9c\ccc44b9d_0271c901\CommunityServer.Files.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\8f6bcff7\952bb26b_3f6fc901\Telerik.Web.UI.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\cf02a1cd\e1c3a59b_0271c901\CommunityServer.Discussions.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\0bb7d412\6ef64fa3_0271c901\CommunityServer.Reporting.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\253e7502\9260b2a7_611dc801\ComponentArt.Web.UI.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\4c818d70\84ab3ea1_0271c901\CommunityServer.MailGateway.MailRoom.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\5c8f81b5\a4a62f1d_621dc801\SgmlReaderDll.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\2ed4866f\ba5339a7_0271c901\CommunityServer.SqlDataProvider.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\bab9fbe9\57d929d6_8820c801\Telligent.CommunityServer.EncryptionModule.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\aa7fd24f\281b6491_611dc801\CommunityServer.MailGateway.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\5a4898b7\6448d090_611dc801\CommunityServer.Mail.Common.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\e8a14d3b\6498a062_621dc801\Telligent.Web.UI.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\b0de1eb2\260cf11a_621dc801\RssToolkit.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\701bbea7\f29733fa_147ec801\RadRotator.Net2.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\App_GlobalResources.yzwwixq6.dll" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\f3080fa5\40c86a7c_611dc801\App_Licenses.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\11765cd2\72899b26_157ec801\Telerik.QuickStart.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\93aa3be0\def11fc5_147ec801\RadChart.Net2.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\da566838\da395a5e_621dc801\Telligent.DynamicConfiguration.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\7251232c\ad87d494_0271c901\CommunityServer.Components.SearchBarrel.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\0c4ecaee\968bf261_621dc801\Telligent.Tasks.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Runtime.Serialization\3.0.0.0__b77a5c561934e089\System.Runtime.Serialization.dll" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\e634f060\87285fa2_0271c901\CommunityServer.Reader.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\15f3c0f5\7e8f5b00_157ec801\RadSplitter.Net2.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\f423d14e\b0e909c1_611dc801\Microsoft.Web.Atlas.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\0941ace6\38ce4fb0_611dc801\MetaBuilders.WebControls.MasterPages.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\caec19d8\0ad906b9_147ec801\RadCalendar.Net2.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\0f96703b\4ab9c3ab_147ec801\DictionaryConfiguration.NET2.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\cdee0804\20b9aca8_611dc801\CookComputing.XmlRpc.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\83c9820b\71f020b5_0271c901\CommunityServer.ASPNet20MemberRole.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\e9936e72\5294325d_621dc801\Telligent.CommunityServer.Metadata.Extractor.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\e4e52c8f\d2c6ce22_157ec801\Telerik.Charting.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\6e12ce0c\337632a4_0271c901\CommunityServer.RollerBlogs.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\3a89dd2a\885e6dfd_611dc801\RadInput.Net2.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\82c82a0d\00e90cc3_611dc801\RadAjax.Net2.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\259c053d\9196cfda_8820c801\Telligent.CommunityServer.SecurityModules.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\19d26ea6\07d340b4_0271c901\Telligent.TinyMCEWrapper.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\4c80696f\b0707e9f_0271c901\CommunityServer.Galleries.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\a1a9ddd9\308d8899_0271c901\CommunityServer.Controls.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\5bda985a\9ddd4da0_0271c901\CommunityServer.IPBanning.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\e67a5c52\9a3c15c9_147ec801\RadDock.Net2.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\acb99cf7\68f0b661_621dc801\Telligent.Registration.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\d612af8e\9eccf693_0271c901\CommunityServer.Components.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\ba207a62\4004c719_621dc801\RadWindow.Net2.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\605202c9\f24ca2a9_611dc801\CookComputing.XmlRpcV2.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\1a4a1cec\daaf05f8_147ec801\RadPanelbar.Net2.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel.Web\3.5.0.0__31bf3856ad364e35\System.ServiceModel.Web.dll" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\75a0b3e2\c2b4ef05_157ec801\RadToolbar.Net2.DLL" /R:"C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\1.0.61025.0__31bf3856ad364e35\System.Web.Extensions.dll" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\31150710\d6a706a5_0271c901\CommunityServer.Spam.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\d0f228c1\e654bff3_147ec801\RadMenu.Net2.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\0f9cf2d2\3e8122b0_611dc801\FreeTextBox.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\a6967809\0033fb90_611dc801\CommunityServer.Mail.Data.SqlDataProvider.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\App_global.asax.zq0chpxo.dll" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\3ac0905e\86ef7ab3_0271c901\Telligent.MailGateway.Common.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.WorkflowServices\3.5.0.0__31bf3856ad364e35\System.WorkflowServices.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\8ae68da3\6af0d2b0_611dc801\Microsoft.AtlasControlExtender.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\cc7ed787\dc000b92_611dc801\CommunityServer.Points.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\b7fe967f\088e69e1_611dc801\RadEditor.Net2.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\d9d88451\76ad911a_621dc801\RSS.NET.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\aac6611a\253e748d_0271c901\CommunityServer.Blogs.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\12ae643f\82cd1009_157ec801\RadTreeView.Net2.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\c4f4175d\76a4a6fc_147ec801\RadSpell.NET2.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.IdentityModel\3.0.0.0__b77a5c561934e089\System.IdentityModel.dll" /R:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll" /R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\c0a00c0a\c29ae50b_157ec801\RadUpload.Net2.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\b7854683\808e0fe3_3e6fc901\RadGrid.Net2.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\68b65c06\1675b714_157ec801\SessionDataSource.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.ServiceModel\3.0.0.0__b77a5c561934e089\System.ServiceModel.dll" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\d096312c\4a5e66b2_0271c901\Telligent.Glow.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\033d178a\960e2203_157ec801\RadTabStrip.Net2.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\786a0daa\12a5a4af_0271c901\Telligent.Components.DLL" /R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\1b365e63\52a5b7c6_147ec801\RadComboBox.Net2.DLL" /R:"C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\App_Code.cyckm-uv.dll" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\23f21310\4c5e06a8_0271c901\CommunityServer.Urls.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\54c9571d\124c682a_157ec801\Telerik.Web.Design.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\713e5e23\300aaf7d_611dc801\AtlasControlToolkit.DLL" /R:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\assembly\dl3\e5c7ddaf\ae26a3ae_0271c901\CommunityServer.Web.DLL" /out:"d:\ASPNetTemp\root\de3a35ae\f1a4e206\App_Web_snq6lq82.dll" /D:DEBUG /debug+ /optimize- /w:4 /nowarn:1659;1699;1701  "d:\ASPNetTemp\root\de3a35ae\f1a4e206\App_Web_snq6lq82.0.cs" "d:\ASPNetTemp\root\de3a35ae\f1a4e206\App_Web_snq6lq82.1.cs" "d:\ASPNetTemp\root\de3a35ae\f1a4e206\App_Web_snq6lq82.2.cs"


Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.3053
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.

d:\domains\nuclearstreet.com\Jobs\sendemail.aspx.cs(51,13): warning CS0168: The variable 'smtpEx' is declared but never used
d:\domains\nuclearstreet.com\Jobs\sendemail.aspx.cs(55,13): warning CS0168: The variable 'ex' is declared but never used
d:\domains\nuclearstreet.com\Jobs\sendemail.aspx.cs(912304,14): error CS0030: Cannot convert type 'ASP.jobs_sendemail_aspx' to 'CommunityServer.Components.CSPage'

 
0
 
CyberzonesAuthor Commented:
Hey, I got it to compile by putting the code on one page!

My problem now is the email does not send? You click the send button and the page just flickers and stays the same. No error, no nothing.

Any ideas?

Here is the code for the web.config:
<system.net>
    <mailSettings>
      <smtp>
        <network host="mailserver.com" port="587" userName="name@test.com" password="password" />
      </smtp>
    </mailSettings>
  </system.net>


New Page code:

<%@ Page Language="C#" %>
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<%@ Import Namespace="System" %>
<%@ Import Namespace="System.Net.Mail" %>
 
 <script language="C#" runat="server">
    
         protected void Page_Load(object sender, EventArgs e)
         {
 
         }
         protected void btnSend_Click(object sender, EventArgs e)
         {
             SendMail();
         }
 
         /// &lt;summary&gt;
         /// Sends email asynchronously.
         /// &lt;/summary&gt;
         private void SendMail()
         {
             System.Net.Mail.MailMessage mailMessage = new System.Net.Mail.MailMessage();
 
             mailMessage.From = new MailAddress("applicant@test.com");
             mailMessage.To.Add(new MailAddress("employer@test.com"));
 
             mailMessage.Subject = txtSubject.Text.Trim();
             mailMessage.Body = txtBody.Text.Trim();
 
             SmtpClient smtpClient = new SmtpClient();
             Object userState = mailMessage;
 
             //Attach event handler for async callback
             smtpClient.SendCompleted += new SendCompletedEventHandler(smtpClient_SendCompleted);
 
             try
             {
                 //Send the email asynchronously
                 smtpClient.SendAsync(mailMessage, userState);
             }
             catch (SmtpException smtpEx)
             {
                 //Error handling here
             }
             catch (Exception ex)
             {
                 //Error handling here
             }
         }
 
         /// &lt;summary&gt;
         /// Event handler for processing completion information after asynchronous email sent.
         /// &lt;/summary&gt;
         void smtpClient_SendCompleted(object sender, System.ComponentModel.AsyncCompletedEventArgs e)
         {
 
             //Get UserState as MailMessage instance from SendMail()
             MailMessage mailMessage = e.UserState as MailMessage;
 
             if (e.Cancelled)
             {
                 labMessage.Text = "Sending of email message was cancelled. Address=" + mailMessage.To[0].Address;
             }
 
             if (e.Error != null)
             {
                 labMessage.Text = "Error occured, info=" + e.Error.Message;
             }
             else
             {
                 labMessage.Text = "Mail sent successfully";
             }
 
         }    
    
</script>
 
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
   <form id="form1" runat="server">
    <div>
     <p>
      <asp:TextBox ID="txtSubject" runat="server" Columns="50" />
    </p>
    <p>
      <asp:TextBox ID="txtBody" runat="server" TextMode="MultiLine" Rows="5" Columns="60" />
    </p>
    <p>
      <asp:Button ID="btnSend" runat="server" Text="Send Email" 
        onclick="btnSend_Click" /></p>
    <p>
      <asp:Label ID="labMessage" runat="server" /></p>
    </div>
    </form>
</body>
</html>

Open in new window

0
 
sunithnairCommented:
Try printing out the error message instead of suppressing the error
0

Featured Post

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 5
  • 4
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now