Link to home
Start Free TrialLog in
Avatar of MastaGardener
MastaGardener

asked on

Type or namespace name 'aspNetEmail' could not be found

I am developing a page in Visual Studio that will send me an email with the comments the user leaves on the page.  To do this I am using a program called aspNetEmail which is a component provided by my hosting company.  However, to use this component in visual studio I have to have the dll (aspNetEmail.dll).  I obtained the dll and added it as a reference to the project, as a solution item, and as an existing item.  All of these produced the same result. ** CS0246: The type or namespace name 'aspNetEmail' could not be found (are you missing a using directive or an assembly reference?)**  Here is the code I am using:

using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
using aspNetEmail;

namespace MastaGardener
{
      /// <summary>
      /// Summary description for comments.
      /// </summary>
      public class comments : System.Web.UI.Page
      {
            protected System.Web.UI.WebControls.TextBox txtName;
            protected System.Web.UI.WebControls.TextBox txtComments;
            protected System.Web.UI.WebControls.Button btnSubmit;
            protected System.Web.UI.WebControls.TextBox txtEmail;
      
            private void Page_Load(object sender, System.EventArgs e)
            {
                  // Put user code to initialize the page here
            }
      
            #region Web Form Designer generated code
            override protected void OnInit(EventArgs e)
            {
                  //
                  // CODEGEN: This call is required by the ASP.NET Web Form Designer.
                  //
                  InitializeComponent();
                  base.OnInit(e);
            }
            
            /// <summary>
            /// Required method for Designer support - do not modify
            /// the contents of this method with the code editor.
            /// </summary>
            private void InitializeComponent()
            {    
                  this.btnSubmit.Click += new System.EventHandler(this.btnSubmit_Click);
                  this.Load += new System.EventHandler(this.Page_Load);

            }
            #endregion

            private void btnSubmit_Click(object sender, System.EventArgs e)
            {
                  //EmailMessage msg = new EmailMessage("localhost");
                  aspNetEmail.EmailMessage msg = new aspNetEmail.EmailMessage("localhost");
                  msg.FromAddress = txtEmail.Text;
                  msg.To = "helloworld@aol.com";
                  msg.Subject = "Comments & Suggestions";
                  msg.Body = txtComments.Text;
                  msg.ThrowException= false;
                  if ( msg.Send() )
                  {
                        Response.Write( "message sent!");
                  }
                  else
                  {
                        Response.Write( msg.LastException().Message );
                  }
            }
      }
}

The project rebuilds fine this way without errors, but pitches a fit when I go to view the page.  The other this is that when I type "aspNetEmail." the drop down box appears for me to choose something.  I'm not really sure what is going on.  Help asap appreciated!
Avatar of Razzie_
Razzie_

Do you mean by viewing the page after deploying? So not when starting from VS.NET?

If you mean viewing it not from VS.NET but really 'live', check how the reference is added. Check if the 'copy local' property is set to true. If it is, the aspNetEmail component is copied to your build folder. If it is set to false, it will just create a reference to the path of the dll file. Upon deploying the project on another server or something, this directory may not exist. In fact, the complete component might not even exist when it is not copied to the build folder.

HTH,

Razzie
Avatar of MastaGardener

ASKER

Hi Razzie

I've got the 'copy local' property set to true.  Right now I'm testing it on IIS on my development computer, not the main server.  So I haven't actually had to move the project to the main server.  Everything has stayed right were it was when I began development.  I view the page in IE.  I've also checked the bin folder to see if the dll was there, and it was after I had set the 'copy local' property to true.

Thanks - Steve
ASKER CERTIFIED SOLUTION
Avatar of glsac
glsac
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial