i would like to create a page on which i would like to create a textbody as body of the e-mail and a button (on click of that button an e-mail will be send to all the current users on my website)
on that same page below that textbox i would like to display a gridview also that shows all the users of my website, that gridview should show: username, e-mail address and membersince
and each row of the gridview should have a check box also so that if i dont want to send newsletters to all users i can select specific users and as the same time there should be a checkbox will select all option so that i can select all also to select all
the rows of the gridview to send e-mail/newsletter to all users
and above that gridview as i mentioned a textbox and a submit button
i would like to create a page on which i would like to create a textbody as body of the e-mail and a button (on click of that button an e-mail will be send to all the current users on my website)
on that same page below that textbox i would like to display a gridview also that shows all the users of my website, that gridview should show: username, e-mail address and membersince
and each row of the gridview should have a check box also so that if i dont want to send newsletters to all users i can select specific users and as the same time there should be a checkbox will select all option so that i can select all also to select all
the rows of the gridview to send e-mail/newsletter to all users
and above that gridview as i mentioned a textbox and a submit button
iam sorry my friend but i dont understand this code, could you please provide me the code for aspx page and code behind the page
and in this situation i am sendind mail to all the users that created account , using aspnet default database, please take that default database example and explain me step by step
thanks for the code my friend but its not working , this is what i am getting (i pasted your code as it is on my page)
AND AT THE SAME TIME your code gives information about some other data like, mobile #, country, DOB etc
but (i dont need the information you have in y our database) i want to send e-mail to all the aspnet_Users who created account by using create user wizard, you can get this database in your aspnet database its a default database, please help me with this
its really important
allright my friends i am still getting error after adding httphandler tag in my webconfig
this is my webconfig
-------
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<httpHandlers>
<add verb="GET" path="FtbWebResource.axd" type="FreeTextBoxControls.AssemblyResourceHandler, FreeTextBox" />
</httpHandlers>
this is the error that i am getting after running the page
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'FreeTextBox' or one of its dependencies. The system cannot find the file specified.
Source Error:
Line 32: -->
Line 33: <httpHandlers>
Line 34: <add verb="GET" path="FtbWebResource.axd" />
ASP__DEVELOP...
Participant
1066 Points
1035 Posts
How to send newsletters to users ?
Oct 20, 2009 01:26 PM|LINK
i would like to create a page on which i would like to create a textbody as body of the e-mail and a button (on click of that button an e-mail will be send to all the current users on my website)
on that same page below that textbox i would like to display a gridview also that shows all the users of my website, that gridview should show: username, e-mail address and membersince
and each row of the gridview should have a check box also so that if i dont want to send newsletters to all users i can select specific users and as the same time there should be a checkbox will select all option so that i can select all also to select all the rows of the gridview to send e-mail/newsletter to all users
and above that gridview as i mentioned a textbox and a submit button
Please provide me the whole code ,,
(Online Forums: ASP.NET, SQL, C#, MS Office, Photoshop and much more)
nhoyti
Member
369 Points
178 Posts
Re: How to send newsletters to users ?
Oct 20, 2009 03:29 PM|LINK
private void SendEmailNotification(DataView notices) { MailMessage mailer; _notificationsFactory = _helper.NotificationsFactory; foreach (DataRowView dr in notices) { int docOwnerID = int.Parse(dr["DocOwnerID"].ToString()); string documentOwner = dr["DocOwner"].ToString(); int totalForReview = int.Parse(dr["TotalForReview"].ToString()); string emailAddress = dr["EmailAddress"].ToString(); int totalGreen = int.Parse(dr["Green"].ToString()); int totalYellow = int.Parse(dr["Yellow"].ToString()); int totalRed = int.Parse(dr["Red"].ToString()); int totalBlue = int.Parse(dr["Blue"].ToString()); mailer = new MailMessage(); //mailer.To = "florentino.tanching@Emerson.com"; if (_helper.IsGenerateNoticesEmailsInDebugMode) mailer.To = _helper.EvergreenMailboxAddress; else mailer.To = emailAddress; mailer.From = _helper.EvergreenMailboxAddress; mailer.Bcc = _helper.EvergreenMailboxAddress; mailer.Subject = "Evergreen Notification -- you own files that are due for review"; mailer.Priority = MailPriority.Normal; mailer.BodyFormat = MailFormat.Html; StringBuilder emailformat = new StringBuilder(); emailformat.AppendLine("<html><head><title>Auto-Email</title></head>"); emailformat.AppendLine("<body><div><font face=\"arial\">"); emailformat.AppendLine("<table width=\"800\" border=\"0\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" style=\"border:2px solid #000066;\">"); emailformat.AppendLine("<tr><td bgcolor=\"#000066\" align=\"center\" height=\"70\"><font color=\"#ffffff\" size=\"7\" face=\"arial\">Evergreen Process</font></td></tr>"); emailformat.AppendLine("<tr><td><table width=\"800\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"); emailformat.AppendLine("<tr><td height=\"25\"><img src=\"http://rosewire2.ep.frco.com/EVGWeb/images/yellow_nav_bar.jpg\"></td></tr>"); emailformat.AppendLine("<tr><td height=\"25\"><img src=\"http://rosewire2.ep.frco.com/EVGWeb/images/gray_nav_bar.jpg\"></td></tr>"); emailformat.AppendLine("</table></td></tr>"); emailformat.AppendLine("<tr><td align=\"center\"><table width=\"750\" height=\"500\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\">"); emailformat.AppendLine("<tr><td valign=\"top\"><table width=\"750\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"); emailformat.AppendLine("<tr><td> </td></tr>"); emailformat.AppendLine("<tr> <td> </td></tr>"); emailformat.AppendLine("<tr><td><font face=\"arial\">Hello <b>" + documentOwner + "</b>,</font></td></tr>"); emailformat.AppendLine("<tr><td> </td></tr>"); emailformat.AppendLine("<tr><td><font face=\"arial\">As part of the Evergreen Process, this email is to inform you that you have <b>" + totalForReview + "</b> file(s) that are due for review. Please login to the Evergreen Process website and view your Batch Notification Details.</font></td></tr>"); emailformat.AppendLine("<tr><td> </td></tr>"); emailformat.AppendLine("<tr><td><font face=\"arial\"><a href=\"http://rosewire2.ep.frco.com/evgweb/Login.aspx\">http://rosewire2.ep.frco.com/evgweb/Login.aspx </a></font></td></tr>"); emailformat.AppendLine("<tr><td> </td></tr>"); emailformat.AppendLine("<tr><td><font face=\"arial\">As a file owner, your current status is as follows:</font></td></tr>"); emailformat.AppendLine("<tr><td> </td></tr>"); emailformat.AppendLine("<tr><td><table width=\"750\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"); emailformat.AppendLine("<tr><td width=\"75%\"><strong><font color=\"#0000FF\" face=\"arial\">FOR DELETION (14 months and above):</font></strong></td>"); emailformat.AppendLine("<td width=\"25%\" align=\"center\"><strong><font color=\"#0000FF\" face=\"arial\">" + totalBlue + "</font></strong></td></tr>"); emailformat.AppendLine("<tr><td width=\"75%\"><strong><font color=\"#FF0000\" face=\"arial\">OVERDUE FOR REVIEW (12-13 months):</font></strong></td>"); emailformat.AppendLine("<td width=\"25%\" align=\"center\"><strong><font color=\"#FF0000\" face=\"arial\">" + totalRed + "</font></strong></td></tr>"); emailformat.AppendLine("<tr><td width=\"75%\"><strong><font color=\"#FFCC00\" face=\"arial\">DUE FOR REVIEW (9 to 12 months old): </font></strong></td>"); emailformat.AppendLine("<td width=\"25%\" align=\"center\"><strong><font color=\"#FFCC00\" face=\"arial\">" + totalYellow + "</font></strong></td></tr>"); emailformat.AppendLine("<tr><td width=\"75%\"><strong><font color=\"#009900\" face=\"arial\">CURRENT (1 to 9 months old):</font></strong></td>"); emailformat.AppendLine("<td width=\"25%\" align=\"center\"><strong><font color=\"#009900\" face=\"arial\">" + totalGreen + "</font></strong></td></tr>"); emailformat.AppendLine("<tr><td width=\"75%\"> </td><td width=\"25%\" align=\"center\" face=\"arial\"> </td></tr></table></td></tr>"); emailformat.AppendLine("<tr><td><font color=\"#0000FF\" face=\"arial\"><i>**Please note that starting October 1, 2009, all files falling under the “For Deletion” (blue) category will be deleted in the respective web site where it is currently posted. We encourage that you review your files especially the ones under the blue category before October 1 to avoid unnecessary posting deletions.</i></font></td></tr>"); emailformat.AppendLine("<tr><td> </td></tr>"); emailformat.AppendLine("<tr><td><font face=\"arial\">In the batch notification page, you may disregard items with “Reviewed Date” in <font color=\"#FF0000\">red font</font>, this means that you have recently reviewed the document and it is pending for administrator’s update.</font></td></tr>"); emailformat.AppendLine("<tr><td> </td></tr>"); emailformat.AppendLine("<tr><td><font face=\"arial\">If you have any questions, please email: <a href=\"mailto:Evergreen.EPM-RTC@Emerson.com\">Evergreen.EPM-RTC@Emerson.com</a></font></td></tr>"); emailformat.AppendLine("<tr><td> </td></tr>"); emailformat.AppendLine("<tr><td><font face=\"arial\">Thank you for your help in keeping our files current and accurate!</font></td></tr>"); emailformat.AppendLine("<tr><td> </td></tr>"); emailformat.AppendLine("<tr><td> </td></tr>"); emailformat.AppendLine("<tr><td><font face=\"arial\">Regards,</font></td></tr>"); emailformat.AppendLine("<tr><td><font face=\"arial\"><b>Evergreen Process Team</b></font></td></tr>"); emailformat.AppendLine("<tr><td> </td></tr></table></td></tr>"); emailformat.AppendLine("</table></td></tr>"); emailformat.AppendLine("<tr><td bgcolor=\"#000066\"><table width=\"800\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">"); emailformat.AppendLine("<tr><td align=\"center\"><font size=\"1\" color=\"#CCCCCC\" face=\"arial\">Contents of the Emerson Process Management Intranet are for internal use only.</font></td></tr>"); emailformat.AppendLine("<tr><td align=\"center\"><font size=\"1\" color=\"#CCCCCC\" face=\"arial\">Copyright © 2009 Emerson Process Management. All rights reserved.</font></td></tr>"); emailformat.AppendLine("</table></td></tr></table>"); emailformat.AppendLine("</font></div></body></html>"); mailer.Body = emailformat.ToString(); SmtpMail.Send(mailer); // update LastNoticeSentDate _notificationsFactory.UpdateLastNoticeSentDate(docOwnerID); } this.Master.ResetErrorMessages(); this.Master.SetSuccessMessage(string.Format( "{0} e-mail notice(s) was successfully sent!", notices.Count)); log.Info(string.Format( "{0} | GenerateNotices.aspx | SendEmailNotification() | Total Emails Sent: {1}", _user.Username, notices.Count)); SetViewNoResults(); }On your button click event. Just call the method SendEmailNotification
Nhoyti
*A newbie C# programmer*
ASP__DEVELOP...
Participant
1066 Points
1035 Posts
Re: How to send newsletters to users ?
Oct 21, 2009 03:18 PM|LINK
iam sorry my friend but i dont understand this code, could you please provide me the code for aspx page and code behind the page
and in this situation i am sendind mail to all the users that created account , using aspnet default database, please take that default database example and explain me step by step
(Online Forums: ASP.NET, SQL, C#, MS Office, Photoshop and much more)
Qin Dian Tan...
All-Star
113532 Points
12480 Posts
Microsoft
Re: How to send newsletters to users ?
Oct 23, 2009 09:33 AM|LINK
Hi ASP__DEVELOPER,
Handle the Click event of submit button:
using System.IO;
using System.Text;
using System.Net.Mail;
protected void SubmitButton_Click(object sender, EventArgs e)
{
foreach (GridViewRow gvr in GridView1.Rows)
{
CheckBox cb = (CheckBox)gvr.FindControl("CheckBox1");
if (cb.Checked)
{
MailMessage mail = new MailMessage();
mail.Body = TextBox_body.Text + gvr.Cells[1].Text + ;
mail.IsBodyHtml = true;
mail.Sender.Address = ((Label)gvr.FindControl("Label_email")).Text;
//...
}
}
}
http://msdn.microsoft.com/en-us/library/system.net.mail.mailmessage(VS.80).aspx
Thanks,
If you have any feedback about my replies, please contactmsdnmg@microsoft.com.
Microsoft One Code Framework
stanly
Star
13201 Points
2490 Posts
Re: How to send newsletters to users ?
Oct 23, 2009 09:43 AM|LINK
<%@ Page Language="C#" MasterPageFile="~/Admin/TarasAdmin.master" AutoEventWireup="true" CodeFile="Mail.aspx.cs" Inherits="Admin_Default2" EnableEventValidation="false" ValidateRequest="false" ViewStateEncryptionMode="Never"%> <%@ Register TagPrefix="FTB" Namespace="FreeTextBoxControls" Assembly="FreeTextBox" %> <asp:Content ID="Content1" ContentPlaceHolderID="head" Runat="Server"> <style type="text/css"> .style1 { width: 100%; } </style> <script language="javascript"> function check_uncheck(Val) { var ValChecked = Val.checked; var ValId = Val.id; var frm = document.forms[0]; // Loop through all elements for (i = 0; i < frm.length; i++) { // Look for Header Template's Checkbox //As we have not other control other than checkbox we just check following statement if (this != null) { if (ValId.indexOf('CheckAll') != - 1) { // Check if main checkbox is checked, // then select or deselect datagrid checkboxes if (ValChecked) frm.elements[i].checked = true; else frm.elements[i].checked = false; } else if (ValId.indexOf('deleteRec') != - 1) { // Check if any of the checkboxes are not checked, and then uncheck top select all checkbox if (frm.elements[i].checked == false) frm.elements[1].checked = false; } } // if } // for } // funct </script><script type="text/javascript"> function confirmMsg(frm) { // loop through all elements for (i = 0; i < frm.length; i++) { // Look for our checkboxes only if (frm.elements[i].name.indexOf("deleteRec") != - 1) { // If any are checked then confirm alert, otherwise nothing happens if (frm.elements[i].checked) return confirm('Are you sure you want to delete your selection(s)?') } } } </script> </asp:Content> <asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server"> <table class="style1"> <tr> <td> </td> <td> <asp:GridView ID="gvUsers" runat="server" AllowSorting="True" AutoGenerateColumns="False"> <Columns> <asp:TemplateField> <HeaderTemplate> <asp:CheckBox ID="CheckAll" runat="server" onclick="return check_uncheck (this );" /> Select AllSelect All </HeaderTemplate> <ItemTemplate> <asp:Label ID="lblMobile" runat="server" Text='<%# DataBinder.Eval (Container.DataItem, "Email") %>' Visible="false" /> <asp:Label ID="RId" runat="server" Text='<%# DataBinder.Eval (Container.DataItem, "RId") %>' Visible="false" /> <asp:CheckBox ID="deleteRec" runat="server" onclick="return check_uncheck (this );" Text='<%# Eval("Email") %>' /> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="RId" HeaderText="RId" InsertVisible="False" ReadOnly="True" SortExpression="RId" /> <asp:BoundField DataField="Mobile" HeaderText="Mobile" SortExpression="Mobile" /> <asp:TemplateField> <ItemTemplate> <asp:HyperLink ID="HyperLink1" runat="server" NavigateUrl='<%#"UserDetails.aspx?RId=" + Eval("RId")%>' Text='<%# Bind("Name") %>'></asp:HyperLink> </ItemTemplate> </asp:TemplateField> <asp:BoundField DataField="Mobile" HeaderText="MobileNumber" SortExpression="Mobile" /> <asp:BoundField DataField="DOB" HeaderText="DOB" SortExpression="DOB" /> </Columns> <EmptyDataTemplate> No data found </EmptyDataTemplate> </asp:GridView> </td> <td> </td> </tr> <tr> <td> Subject</td> <td> <asp:TextBox ID="txtSubject" runat="server"></asp:TextBox> </td> <td> </td> </tr> <tr> <td> Mail</td> <td> <FTB:FreeTextBox ID="txtBody" runat="server"></FTB:FreeTextBox> </td> <td> </td> </tr> <tr> <td> </td> <td> <asp:Button ID="btnSend" runat="server" Text="Send" onclick="btnSend_Click" /> </td> <td> </td> </tr> </table> </asp:Content>.CS code:
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.Data.SqlClient; using System.Net.Mail; using System.Text; public partial class Admin_Default2 : System.Web.UI.Page { string s; string sql; SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["TarasConnectionString"].ConnectionString); protected void Page_Load(object sender, EventArgs e) { try { sql = "Select * from Users where Country='IN'"; con.Open(); SqlDataAdapter da = new SqlDataAdapter(sql, con); DataTable dt = new DataTable(); DataSet ds = new DataSet(); da.Fill(ds); da.Fill(dt); gvUsers.DataSource = ds; gvUsers.DataBind(); con.Close(); } catch { } } protected void btnSend_Click(object sender, EventArgs e) { string gvIDs = ""; bool chkBox = false; //'Navigate through each row in the GridView for checkbox items foreach (GridViewRow gv in gvUsers.Rows) { CheckBox deleteChkBxItem = (CheckBox)gv.FindControl("deleteRec"); if (deleteChkBxItem.Checked) { chkBox = true; // Concatenate GridView items with comma for SQL Delete gvIDs += ((Label)gv.FindControl("lblMobile")).Text.ToString() + ","; } } Response.Write(gvIDs.Substring(0, gvIDs.LastIndexOf(","))); s = gvIDs.Substring(0, gvIDs.LastIndexOf(",")); AlternateView View = null; LinkedResource resource = null; SmtpClient client = null; StringBuilder msgText = new StringBuilder(); MailMessage msg = new MailMessage("stanly@stanly.com", s); msg.Body = txtBody.Text; msg.Subject = "Welcome to TarasJewellery.com"; // msg.From = new MailAddress(email, "Taras Jewellery"); msg.IsBodyHtml = true; View = AlternateView.CreateAlternateViewFromString(msgText.ToString(), null, "text/html"); SmtpClient smtpClient = new SmtpClient(); smtpClient.Host = "relay-hosting.secureserver.net"; smtpClient.Credentials = new System.Net.NetworkCredential("stanly@stanly.com", "stanly"); smtpClient.Send(msg); } }Same thing i've done... its working...
weblogs.asp.net/stanly
ASP__DEVELOP...
Participant
1066 Points
1035 Posts
Re: How to send newsletters to users ?
Oct 23, 2009 03:05 PM|LINK
thanks for the code my friend but its not working , this is what i am getting (i pasted your code as it is on my page)
AND AT THE SAME TIME your code gives information about some other data like, mobile #, country, DOB etc
but (i dont need the information you have in y our database) i want to send e-mail to all the aspnet_Users who created account by using create user wizard, you can get this database in your aspnet database its a default database, please help me with this its really important
(Online Forums: ASP.NET, SQL, C#, MS Office, Photoshop and much more)
stanly
Star
13201 Points
2490 Posts
Re: How to send newsletters to users ?
Oct 24, 2009 04:34 AM|LINK
<add verb="GET" path="FtbWebResource.axd" type="FreeTextBoxControls.AssemblyResourceHandler, FreeTextBox" />
add this in web.config file... inside <httpHandlers> tag
weblogs.asp.net/stanly
ASP__DEVELOP...
Participant
1066 Points
1035 Posts
Re: How to send newsletters to users ?
Oct 26, 2009 01:40 PM|LINK
but i dont see any <httphandlers> tag in my webconfig...
(Online Forums: ASP.NET, SQL, C#, MS Office, Photoshop and much more)
rtpHarry
All-Star
56620 Points
8958 Posts
Re: How to send newsletters to users ?
Oct 27, 2009 12:36 AM|LINK
It should be there, try searching for it if you can't see it.
If it really isn't there then you can just create it - it goes in <system.web>:
ASP__DEVELOP...
Participant
1066 Points
1035 Posts
Re: How to send newsletters to users ?
Oct 27, 2009 03:07 PM|LINK
thanks harry for giving me directions
allright my friends i am still getting error after adding httphandler tag in my webconfig
this is my webconfig
-------
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<httpHandlers>
<add verb="GET" path="FtbWebResource.axd" type="FreeTextBoxControls.AssemblyResourceHandler, FreeTextBox" />
</httpHandlers>
<compilation debug="true" strict="false" explicit="true"/>
<pages>
-----------------------------
this is my aspx page source:
---------
This is the design view of my aspx page
----------------
this is the error that i am getting after running the page
Configuration Error
Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.
Parser Error Message: Could not load file or assembly 'FreeTextBox' or one of its dependencies. The system cannot find the file specified.
Source Error:
---------
Please guide me my friends...Please HELP
(Online Forums: ASP.NET, SQL, C#, MS Office, Photoshop and much more)