Urgent: I need to create a new page with a fill in form, How ?

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.
13 years ago
Thanks worked a treat for me!
13 years ago
Hello,

i also need a custom form, i try with "MemberInfo.aspx" code, but i have a Parser Error Message: "Could not load type 'NopSolutions.NopCommerce.Web.MemberInfo'."

Could you help me??
13 years ago
You probably did not copy codes for MemberInfo.aspx.cs  or you have changed namespace/class name.
13 years ago
Thanks, it was really an error with the class name, your MemberInfo.aspx works perfectly.

Now I'm trying to do something slightly different: from ShoppingCart.aspx I need attach a fill in form that send me a mail with names of products in shoppingcart;

no problem sending email (with MemberInfo.aspx code) but i don't konw how to put in the e mail products full name showed in shoppingcart repeater control.

Can you help me??

Thanks in advance
13 years ago
hkhieu wrote:
Here you go!

MemberInfo.aspx

<%@ Page Language="C#" MasterPageFile="~/MasterPages/TwoColumn.master" AutoEventWireup="true"
CodeBehind="MemberInfo.aspx.cs" Inherits="NopSolutions.NopCommerce.Web.MemberInfo" %>
<asp:Content ID="Content1" ContentPlaceHolderID="cph1" runat="server">
    <asp:Label ID="ResultLabel" ForeColor="Red" runat="server" ></asp:Label><br />
    Name: <asp:TextBox ID="NameTextBox" runat="server"></asp:TextBox><br />
    Company: <asp:TextBox ID="CompanyTextBox" runat="server"></asp:TextBox><br />
    Contact #: <asp:TextBox ID="ContactNumberTextBox" runat="server"></asp:TextBox><br />
    Mobile phone: <asp:TextBox ID="MobilePhoneTextBox" runat="server"></asp:TextBox><br />
    Address: <asp:TextBox ID="AddressTextBox" runat="server"></asp:TextBox><br />
    # of Attendants: <asp:TextBox ID="AttendantTextBox" runat="server"></asp:TextBox><br /><br />
    <asp:Button ID="SubmitButton" runat="server" Text="Submit"
        onclick="SubmitButton_Click" />
</asp:Content>

MemberInfo.aspx.cs

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using NopSolutions.NopCommerce.BusinessLogic.Messages;

namespace NopSolutions.NopCommerce.Web
{
    public partial class MemberInfo : BaseNopPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            string mailContent = string.Format("Name: {0}, Company:{1}, Contact#:{2}, Mobilephone:{3}, Address:{4},  Attendants:{5}",  NameTextBox.Text, CompanyTextBox.Text, ContactNumberTextBox.Text,
                                            MobilePhoneTextBox.Text, AddressTextBox.Text, AttendantTextBox.Text);
            try
            {
                MailAddress from = new MailAddress(MessageManager.AdminEmailAddress, MessageManager.AdminEmailDisplayName);
                MailAddress to = new MailAddress("[email protected]");
                MessageManager.SendEmail("Member Info", mailContent, from, to);
                ResultLabel.Text = "email successfully sent";
            }
            catch (Exception ex)
            {
                ResultLabel.Text = "Error: " + ex.Message;
            }
        }
    }
}

Add it to nopCommerceStore root folder, create a link some where to it and you ready to go.
I am not a graphic designer, so you make it beautiful yourself. But most importantly, It runs.


i want to define multiple recievers for the information send by this form, how i can do that ?

I have tried doing this:

MailAddress to = new MailAddress("[email protected], [email protected], [email protected]");

This sends e-mail to only last e-mail address and skip first 2, why ?

same with ";", when i use semicolon same thing happens

But when i use "," and i don't give spaces in between e-mail addresses, then i get error saying ", unrecognized symbol used"

Please help...
13 years ago
Try this way:

var to1 = new MailAddress("[email protected]");
var to2 = new MailAddress("[email protected]");
var to3 = new MailAddress("[email protected]");
List<MailAddress> recipients = new List<MailAddress>();
recipients.Add(to1);
recipients.Add(to2);
recipients.Add(to3);
foreach (MailAddress to in recipients)
       {
             MessageManager.InsertQueuedEmail(5, from, to, string.Empty, string.Empty, subject, body, DateTime.Now, 0, null);
        }
13 years ago
Is this correct ?


using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Net.Mail;
using NopSolutions.NopCommerce.BusinessLogic.Messages;

namespace NopSolutions.NopCommerce.Web
{
    public partial class Requestaquote : BaseNopPage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
        }

        protected void SubmitButton_Click(object sender, EventArgs e)
        {
            string mailContent = string.Format("Name: {0}, Contact_Number:{1}, E-mail_Address:{2}, Company_Name:{3}, Company_Address:{4},  Enquiry:{5}", NameTextBox.Text, ContactNumberTextBox.Text, EmailTextBox.Text, CompanyTextBox.Text, AddressTextBox.Text, EnquiryTextBox.Text);
            try
            {
                MailAddress from = new MailAddress(MessageManager.AdminEmailAddress, MessageManager.AdminEmailDisplayName);
                var to1 = new MailAddress("[email protected]");
                var to2 = new MailAddress("[email protected]");
                var to3 = new MailAddress("[email protected]");
                List<MailAddress> recipients = new List<MailAddress>();
                recipients.Add(to1);
                recipients.Add(to2);
                recipients.Add(to3);
                foreach (MailAddress to in recipients)
                {
                    MessageManager.InsertQueuedEmail(5, from, to, string.Empty, string.Empty, "Subject", mailContent, DateTime.Now, 0, null);
                }
                
                ResultLabel.Text = "We have received your quote... Thank You !!!";
            }
            catch (Exception ex)
            {
                ResultLabel.Text = "Error: " + ex.Message;
            }
        }
    }
}
13 years ago
I want to add 1 or 2 file upload options in this form, how can i do that ? so that i receive all information along with the file uploaded ?
13 years ago
anyone ?
13 years ago
hi ... a example with fileupload

contato2.aspx


<%@ Page Language="C#" MasterPageFile="~/MasterPages/ThreeColumn.master" AutoEventWireup="true"
    Inherits="NopSolutions.NopCommerce.Web.ContactUsPage" CodeBehind="contato2.aspx.cs"
     %>

<script runat="server">
    protected void Button1_Click(object sender, EventArgs e)
    {
        Button1.Enabled = false;
        try
        {
            System.Net.Mail.MailMessage message = new System.Net.Mail.MailMessage(txtmail.Text, "[email protected]", "your subject", "<html><head></head><body>" + "Nome: " + txtnome.Text + "<br/> " + "Telefone: " + txtfoneres.Text + "<br/>" + "E-mail: " + txtmail.Text + "<br/>" + "Details: " + txtexame.Text + "<br/><br/>" + DateTime.Now.ToString() + " - " + Request.UserHostAddress.ToString() + "</html></body>");
            message.IsBodyHtml = true;

           System.IO.MemoryStream MS = new System.IO.MemoryStream(fileAnexo.FileBytes);

            // Anexa o Stream do arquivo

            System.Net.Mail.Attachment anexo = new System.Net.Mail.Attachment(MS, fileAnexo.FileName);

            message.Attachments.Add(anexo);

            System.Net.Mail.SmtpClient mm = new System.Net.Mail.SmtpClient();
            mm.Send(message);
            lblstatus.Text = "sucessfull message.";
        }
        catch
        {

            lblstatus.Text = "error message!";
        
        }
        
        
        
    }
  
</script>
<asp:Content ID="Content1" ContentPlaceHolderID="cph1" runat="Server">
    <div style="font-family:Tahoma; width:500px; background-color:#FFF; padding:5px; margin-left:20px;">
    <span>Para mais informações sobre locação preencha o formulário abaixo e nossos consultores comerciais entrarão em contato com você.<br /></span><br /><br />
    Nome : <asp:TextBox ID="txtnome" runat="server" Width="260" MaxLength="80" ValidationGroup="g"></asp:TextBox><br />
      
    <br />
    Fone : <asp:TextBox CssClass="phone" ID="txtfoneres" MaxLength="13" runat="server" Width="100" ValidationGroup="g"></asp:TextBox> <br /><br />
    E-mail: <asp:TextBox ID="txtmail" MaxLength="120" runat="server" Width="150" ValidationGroup="g"></asp:TextBox><br /><br />
    
    
    Detalhes:<br />
    <asp:TextBox ID="txtexame" runat="server" TextMode="MultiLine" Width="450" Height="200" ValidationGroup="g"></asp:TextBox><br/>
Anexar Currículo: <asp:FileUpload ID="fileAnexo" runat="server" />

    <asp:Button ID="Button1" runat="server" Text="Enviar" ValidationGroup="g"
            onclick="Button1_Click" UseSubmitBehavior="false" />
        <br />
        <asp:Label ID="lblstatus" runat="server"></asp:Label>
    <br />
    <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="Nome Requerido" ControlToValidate="txtnome" SetFocusOnError="True" ValidationGroup="g"></asp:RequiredFieldValidator>
    <br />
    <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ErrorMessage="Tel. Requerido" ControlToValidate="txtfoneres" SetFocusOnError="True" ValidationGroup="g"></asp:RequiredFieldValidator>
    
    <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ErrorMessage="E-mail Requerido" ControlToValidate="txtmail" SetFocusOnError="True" ValidationGroup="g"></asp:RequiredFieldValidator>
    <br />
    <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ErrorMessage="Mensagem Requerida" ControlToValidate="txtexame" SetFocusOnError="True" ValidationGroup="g"></asp:RequiredFieldValidator>
    <br />
    <asp:regularexpressionvalidator SetFocusOnError="true" ID="Regularexpressionvalidator1" runat="server" errormessage="E-mail Inválido" ControlToValidate="txtmail" ValidationGroup="g" ValidationExpression="^(?(&quot;&quot;)(&quot;&quot;.+?&quot;&quot;@)|(([0-9a-zA-Z]((\.(?!\.))|[-!#\$%&'\*\+/=\?\^`\{\}\|~\w])*)(?<=[0-9a-zA-Z])@))(?(\[)(\[(\d{1,3}\.){3}\d{1,3}\])|(([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,6}))$"></asp:regularexpressionvalidator>
    
    
    
    
    
    </div>

</asp:Content>




in web.config add



<system.net>

    <mailSettings>
      <smtp>
        <network host="mail.yoursmtp.com" port="25" userName="[email protected]" password="yourpass"/>
      </smtp>
    </mailSettings>
    
  </system.net>

This topic was automatically closed 365 days after the last reply. New replies are no longer allowed.