any member/visitor can type his/her e-mail
upload file
and write addition information and send.
My page form works fine and it sends the information to admin mailbox set in admin section > mail settings
Now i don't want to send e-mail to admin mailbox instead of that i want to define a list of recipients e-mail addresses in the code so that information goes to them instead of admin mailbox. Please guide me
This is my code:
careers.aspx page
<td style="height: 26px; width: 93px; text-align : left">
<b><span style="font-size: 8pt">Your Email:</span></b></td>
<td style="height: 26px; width: 239px;">
<asp:TextBox ID="UsersEmail" runat="server" Columns="30" Height="17px" Width="193px"></asp:TextBox><span
style="font-size: 8pt">*</span>
<td style="height: 24px; width: 239px;">
<asp:FileUpload ID="AttachmentFile" runat="server" Height="26px" Width="239px" />
</td>
<td colspan="1" style="width: 93px">
<strong><span style="font-size: 8pt">Comments:</span></strong></td>
<td>
<strong><span style="font-size: 8pt"></span></strong>
</td>
</tr>
<tr>
<td colspan="2">
<span style="font-size: 8pt"></span>
<asp:TextBox ID="Body" runat="server" Columns="55" Height="130px" Rows="30" TextMode="MultiLine"
Width="342px"></asp:TextBox>
</td>
</tr>
<tr>
<td align="center" colspan="2" style="height: 26px">
<asp:Button ID="SendEmail" runat="server" OnClick="SendEmail_Click" Text="Submit" />
</td>
</tr>
Careers.aspx.cs
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Net.Mail;
using NopSolutions.NopCommerce.BusinessLogic.Messages;
namespace NopSolutions.NopCommerce.Web
{
public partial class Careers : BaseNopPage
{
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
//On the first page load, hide the EmailSentForm Panel
EmailSentForm.Visible = false;
}
}
protected void SendEmail_Click(object sender, EventArgs e)
{
//'Make sure a file has been uploaded
if (!AttachmentFile.HasFile)
{
LBLSuccErr.Text = "Please select a file to upload";
LBLSuccErr.Visible = true;
LBLSuccErr.ForeColor = System.Drawing.Color.Red;
}
else //Upload file to server
{
try
{
MailAddress from = new MailAddress(MessageManager.AdminEmailAddress, MessageManager.AdminEmailDisplayName);
MailAddress to = new MailAddress(MessageManager.AdminEmailAddress, MessageManager.AdminEmailDisplayName);
//'(1) Create the MailMessage instance
MailMessage mm = new MailMessage(from, to);
//'(2) Assign the MailMessage's properties
mm.Subject = "Message Careers";
mm.Body = Body.Text;
mm.IsBodyHtml = false;
//'Attach the file
mm.Attachments.Add(new Attachment(AttachmentFile.PostedFile.InputStream, AttachmentFile.FileName));
MessageManager.SendEmail(mm);
//'Show the EmailSentForm Panel and hide the EmailForm Panel
LBLSuccErr.Visible = true;
LBLSuccErr.ForeColor = System.Drawing.Color.Green;
LBLSuccErr.Text = "Your file has been submitted successfully";
}
catch (SystemException err)
{
LBLSuccErr.Visible = true;
LBLSuccErr.ForeColor = System.Drawing.Color.Red;
LBLSuccErr.Text = err.Message;
}
}
}
}
}