SQL Stored Procedure to Send Email using OLE You Just need to change SMTP Server address CREATE PROCEDURE [dbo].[WSA_sp_SendEmail]@From varchar(100),@To varchar(1000),@Subject varchar(250),@Body varchar(max),@CC varchar(1000) = nullASBEGINDeclare @iMsg intDeclare @hr intDeclare @source varchar(255)Declare @description varchar(500)Declare @output varchar(1000)EXEC @hr = sp_OACreate 'CDO.Message', @iMsg OUTPrint @FromEXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/sendusing").Value','2'EXEC @hr = sp_OASetProperty @iMsg, 'Configuration.fields("http://schemas.microsoft.com/cdo/configuration/smtpserver").Value', '10.0.0.100'EXEC @hr = sp_OAMethod @iMsg, 'Configuration.Fields.Update', null--Print @ToEXEC @hr = sp_OASetProperty @iMsg, 'To', @ToEXEC @hr = sp_OASetProperty @iMsg, 'From', @Fromif (@Cc '')EXEC @hr = sp_OASetProperty @iMsg, 'Cc...
Posts
To Read and Write to Text file from ASP.NET
- Get link
- X
- Other Apps
To Write C# code If the file does not exist you will get an error. You can check to see if the file exists using this code: if (System.IO.File.Exists(Server.MapPath("test.txt"))) To write the contents of a TextBox control to a text file using the System.IO.StreamWriter class use the following code: System.IO.StreamWriter StreamWriter1 = new System.IO.StreamWriter(Server.MapPath("test.txt")); StreamWriter1.WriteLine(TextBox1.Text); StreamWriter1.Close(); Inserting "\r\n" will create a line break in the text file. Adding line breaks from code can be done using this code: StreamWriter1.WriteLine("Some text on line1.\r\nSome text on line2."); To Read c# code System.IO.StreamReader StreamReader1 = new System.IO.StreamReader(Server.MapPath("test.txt")); TextBox2.Text = StreamReader1.ReadToEnd(); StreamReader1.Close();
To Insert Data into Excel using Office object libray
- Get link
- X
- Other Apps
C# file code using System; using System.Data; using System.Configuration; 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 Microsoft.Office.Interop.Excel; using System.Reflection; using Microsoft.Office.Core; using System.Drawing; using SAMSBusinessLayer; using SAMSDataAccessLayer; using System.IO; using System.Diagnostics; public partial class Admin_Report_SamsReport : basePageSessionExpire { #region Private_Variable Microsoft.Office.Interop.Excel.Application excelapp; Microsoft.Office.Interop.Excel.Workbook wb; int iSelectedMonth = 0; int iSelectedYear = 0; ExecuteSummaryDataFilter objExecuteSummaryDataFilter; ExecuteSummaryData objExecuteSummaryData; int iRowNo_for_Executive_Summary_Sheet = 1; int iRowNo_for_Slide_Views_Sheet = 1; int iRowNo_for_Fulfillment_Report_Sheet = 1; string Table_Logins_By_Month_StartRange = "...
Export To Excel Even With Special Character in Data
- Get link
- X
- Other Apps
The Following C# code is used to Export data from ASP.NET to Excel with special characters try { Response.ContentType = "application/vnd.ms-excel 8.0"; Response.Charset = ""; Response.ContentEncoding = System.Text.Encoding.Default; this.EnableViewState = false; System.IO.StringWriter ObjWriter = new System.IO.StringWriter(); System.Web.UI.HtmlTextWriter ObjHtmlTextWriter = new System.Web.UI.HtmlTextWriter(ObjWriter); rptUserDetails.RenderControl(ObjHtmlTextWriter); //dgdInitiative is the Grid name which is to be exported Response.Write(ObjWriter.ToString()); string strhtml = ObjHtmlTextWriter.ToString(); Response.AppendHeader("content-disposition", "attachment;filename=Users.xls"); Response.End(); } catch (System.Exception ex) { string strMsg = ex.Message; }
Never cry...
- Get link
- X
- Other Apps
NEVER CRY FOR ANY RELATION IN LIFE BECAUSE FOR THE ONE WHOM YOU CRY DOES NOT DESERVE YOUR TEARS AND THE ONE WHO DESERVES WILL NEVER LET YOU CRY................. TREAT EVERYONE WITH POLITENESS EVEN THOSE WHO ARE RUDE TO YOU, NOT BECAUSE THEY ARE NOT NICE BUT BECAUSE YOU ARE NICE....................... NEVER SEARCH YOUR HAPPINESS IN OTHERS WHICH WILL MAKE YOU FEEL ALONE, RATHER SEARCH IT IN YOURSELF YOU WILL FEEL HAPPY EVEN IF YOU ARE LEFT ALONE...................... ALWAYS HAVE A POSITIVE ATTITUDE IN LIFE. THERE IS SOMETHING POSITIVE IN EVERY PERSON. EVEN A STOPPED WATCH IS RIGHT TWICE A DAY.................................... HAPPINESS ALWAYS LOOKS SMALL WHEN WE HOLD IT IN OUR HANDS. BUT WHEN WE LEARN TO SHARE IT, WE REALIZE HOW BIG AND PRECIOUS IT IS!...
To Move items from one ListBox to another Listbox
- Get link
- X
- Other Apps
To Develop a page with the following type of requirement I had used the server side methods for this of asp.net and use updatepanel from ajaxtoolkit to avoid postback to the page. The aspx file code:- <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <table> <tr> <td style="width: 100px; height: 104px"> <asp:ListBox ID="lstReturnFields" runat="server" DataTextField="name" DataValueField="start" Rows="6" SelectionMode="Multiple" Width="150px"> </asp:ListBox> </td> <td align="center" style="height: 104px" valign="middle"> <asp:I...