This is my Technical area of troubleshooting and learning new Programming skills and many more. Here you will find answers for many new technologies like asp.net 2.0/3.5,4.0 C# access, mysql, Amazon Webservice ,Sql-server, JD Edwards, SAS, Salesforce, APIs, MVC and many more. please visit & discuss.
Wednesday, December 31, 2008
NEWID() Generating Random Numbers in SQL-Server
Tuesday, December 30, 2008
SalesForce DateTime Webservice Partner API
Tuesday, December 23, 2008
Saturday, December 13, 2008
Wednesday, December 10, 2008
Excel to Sql-server table Complete code C# asp.net 2.0 / 3.5, SqlBulkCopy
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:FileUpLoad id="FileUpLoad1" runat="server" />
<asp:Button id="UploadBtn" Text="Upload File" OnClick="UploadBtn_Click" runat="server" Width="105px" />
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Upload To Sql Table" />
<asp:Label ID="Label1" runat="server" Width="188px"></asp:Label></div>
</form>
</body>
</html>
code Behind
Upload a file using asp.net 2.0 c# and file control sample code
<%
@ Page Language="C#" AutoEventWireup="true" CodeFile="Default5.aspx.cs" Inherits="Default5" %><!
DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><
html xmlns="http://www.w3.org/1999/xhtml" ><
head runat="server"> <title>Untitled Page</title></
head><
body> <form id="form1" runat="server"> <div> <asp:FileUpLoad id="FileUpLoad1" runat="server" /><
asp:Button id="UploadBtn" Text="Upload File" OnClick="UploadBtn_Click" runat="server" Width="105px" /> <asp:Label ID="Label1" runat="server" Width="188px"></asp:Label></div> </form></
body>using
System;using
System.Data;using
System.Configuration;using
System.Collections;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;public
partial class Default5 : System.Web.UI.Page{
protected void Page_Load(object sender, EventArgs e){
}
protected void UploadBtn_Click(object sender, EventArgs e){
if (FileUpLoad1.HasFile){
FileUpLoad1.SaveAs(
@"C:\webfiles\" + FileUpLoad1.FileName);Label1.Text =
"File Uploaded: " + FileUpLoad1.FileName ;}
else{
Label1.Text =
"No File Uploaded.";}
}
}
Sunday, December 7, 2008
Saturday, November 29, 2008
WebPage / Screen Scraping Html to Sql-Server, code sample VB.NET asp.net 2.0
This is the sample in vb asp.net 2.0, sql-server express 2005 if you want to scrap page from url want to insert in sql-server table.
<%@ Page Language="VB" AutoEventWireup="false" CodeFile="htmltosql.aspx.vb" Inherits="htmltosql" validateRequest="false" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox runat="server" id="amzTop" TextMode="MultiLine" Columns="360" Rows="15" /><br />
<asp:Button ID="Button1" runat="server" Text="Button" /><br />
<br />
</div>
</form>
</body>
</html>
Code Behind
Imports System.Data.SqlClient
Imports System
Imports System.IO
Imports System.Xml
Imports System.Net
Partial Class htmltosql
Inherits System.Web.UI.Page
Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles ,Button1.Click
insertdata()
End Sub
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Dim req As HttpWebRequest = WebRequest.Create("http://www.yahoo.com/")
Try
'Get the data as an HttpWebResponse object
Dim resp As HttpWebResponse = req.GetResponse()
'Convert the data into a string (assumes that you are requesting text)
Dim sr As New StreamReader(resp.GetResponseStream())
Dim results As String = sr.ReadToEnd()
sr.Close()
amzTop.Text = results
Catch wex As WebException
Response.Write("<font color=red>SOMETHING WENT AWRY!<br />Status: " & wex.Status & "Message: " & wex.Message & "</font>")
End Try
End Sub
Public Sub insertdata()
'Response.Write(amzTop.Text)
'Response.End()
Dim con As New SqlConnection("Data Source=testserver\SQLEXPRESS;Initial Catalog=test_DV;Integrated Security=True")
Dim cmd As New SqlCommand("insbulkhtml", con)
cmd.CommandType = Data.CommandType.StoredProcedure
cmd.Parameters.AddWithValue("@htmlstr", LTrim(amzTop.Text))
Using con
con.Open()
cmd.ExecuteNonQuery()
End Using
End Sub
End Class
stored proc
Create proc [dbo].[insbulkhtml]
@htmlstr nvarchar(max) as
delete from tem_tab1
INSERT into tem_tab1
select @htmlstr
Table
CREATE TABLE [dbo].[tem_tab1](
[Prodcode] [nvarchar](max) NULL
) ON [PRIMARY]
Tuesday, November 25, 2008
Create a webservice directly from Sql Server 2005 /2008 using an HTTP
use adventureworksgo
CREATE ENDPOINT GetEmployees STATE = STARTEDAS HTTP( PATH = '/Employee', AUTHENTICATION = (INTEGRATED), PORTS = (CLEAR), SITE = 'localhost')FOR SOAP( WEBMETHOD 'EmployeeList' (NAME='AdventureWorks.dbo.GetEmployees'), BATCHES = DISABLED, WSDL = DEFAULT, DATABASE = 'AdventureWorks', NAMESPACE = 'http://AdventureWorks/Employee')
Public Class Form1
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
' Create a new instance of the web service
Dim employeesProxy As adventureWorksService.GetEmployees = New adventureWorksService.GetEmployees
' You have to pass in credentials to authenticate yourself to use the service. We are just going to use
' the same credentials we have logged into our computer as.
employeesProxy.Credentials = System.Net.CredentialCache.DefaultCredentials
' The result of a SELECT statement via an endpoint can be converted to a DataSet
Dim ds As System.Data.DataSet = DirectCast(employeesProxy.EmployeeList, DataSet)
ListBox1.DataSource = ds.Tables(0)
ListBox1.DisplayMember = "FullName"
ListBox1.ValueMember = "EmployeeId"
End Sub
End Class
Saturday, November 22, 2008
Retain Scroll / Page Position After postback c# asp.net
Page.MaintainScrollPositionOnPostBack = true;
<%@ Page MaintainScrollPositionOnPostback="true" %>
<pages maintainScrollPositionOnPostBack="true" />
Friday, November 21, 2008
Correct Date time for salesforce webservice
Salesforce custom field error: - is not a valid value for the type xsd:dateTime
Solution: I got correct result when inputting date format like this:-
2008-11-21T04:37:14-05:00
more on this issue :-
http://community.salesforce.com/sforce/board/message?board.id=NET_development&message.id=4069
CS0117: 'Default1.aspx' does not contain a definition for 'binding'- salesforce sample C# asp.net
Compiler Error Message: CS0103: The name 'sfdc' does not exist in the current context - salesforce sample C# asp.net
'sforce.sObject' does not contain a definition for 'Any'- salesforce sample C# asp.net
Wednesday, November 19, 2008
Asp.net 2.0 login controls C# Access database sample code
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Login ID="Login1" runat="server" OnAuthenticate="Login1_Authenticate"
BackColor="Transparent" BorderColor="#ffccff" BorderPadding="4" BorderStyle="Solid"
BorderWidth="0px" Font-Names="Verdana" Font-Size="10px" ForeColor="#333333"
Height="53px" Width="100%" >
<TitleTextStyle BackColor="#507CD1" Font-Bold="True" Font-Size="0.9em" ForeColor="White" />
<InstructionTextStyle Font-Italic="True" ForeColor="Black" />
<TextBoxStyle Font-Size="1.2em" />
<LoginButtonStyle BackColor="White" BorderColor="#507CD1" BorderStyle="Solid" BorderWidth="1px"
Font-Names="Verdana" Font-Size="12px" ForeColor="#284E98" />
<LayoutTemplate>
<table border="0" cellpadding="4" cellspacing="0" style="border-collapse: collapse; height: 99px;">
<tr>
<td align="left">
<table border="0" cellpadding="0" style="width: 100%; height: 25%">
<tr>
<td align="right">
<asp:Label ID="UserNameLabel" runat="server" AssociatedControlID="UserName" Font-Bold="True" ForeColor="White" Font-Size="10px">User Name:</asp:Label></td>
<td align="left">
<asp:TextBox ID="UserName" runat="server" Font-Size="10px" BackColor="#FFFFC0" Font-Bold="False"></asp:TextBox>
<asp:RequiredFieldValidator ID="UserNameRequired" runat="server" ControlToValidate="UserName"
ErrorMessage="User Name is required." ToolTip="User Name is required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
</td>
</tr>
<tr>
<td align="right" style="height: 23px">
<asp:Label ID="PasswordLabel" runat="server" AssociatedControlID="Password" Font-Bold="True" ForeColor="White" Font-Size="10px">Password:</asp:Label></td>
<td align="left" style="height: 23px">
<asp:TextBox ID="Password" runat="server" Font-Size="10px" TextMode="Password" BackColor="#FFFFC0" Font-Bold="False"></asp:TextBox>
<asp:RequiredFieldValidator ID="PasswordRequired" runat="server" ControlToValidate="Password"
ErrorMessage="Password is required." ToolTip="Password is required." ValidationGroup="Login1">*</asp:RequiredFieldValidator>
<asp:Button ID="LoginButton" runat="server" BackColor="White" BorderColor="#507CD1"
BorderStyle="Solid" BorderWidth="1px" CommandName="Login" Font-Names="Verdana"
Font-Size="11px" ForeColor="#284E98" Text="Log In" ValidationGroup="Login1" OnClick="LoginButton_Click" />
</td>
</tr>
<tr>
<td colspan="2" align="left">
<asp:CheckBox ID="RememberMe" runat="server" Text="Remember me" Font-Bold="False" ForeColor="White" />
</td>
</tr>
<tr>
<td align="center" colspan="2" style="color: red; height: 16px;">
<asp:Literal ID="FailureText" runat="server" EnableViewState="False"></asp:Literal>
</td>
</tr>
</table>
<strong><span style="color: #ffff33"></span></strong></td>
</tr>
</table>
</LayoutTemplate>
</asp:Login>
</div>
</form>
</body>
</html>
-----
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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.OleDb;
{
string CaseIDClient;
protected void Page_Load(object sender, EventArgs e)
{
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
bool Authenticated = false;
Authenticated = SiteLevelCustomAuthenticationMethod(Login1.UserName, Login1.Password);
e.Authenticated = Authenticated;
if (Authenticated == true)
{
Response.Redirect("dispcase.aspx");
if (Session["userRole"].ToString() == "client")
{
Response.Redirect("clientcasestatus.aspx?caseID=" + CaseIDClient);
}
else
{
Response.Redirect("dispcase.aspx");
}
*/
}
private bool SiteLevelCustomAuthenticationMethod(string UserName, string Password)
{
OleDbConnection conDatabase = null;
OleDbDataReader Dr = null;
string strUserID = UserName;
conDatabase = new OleDbConnection("Provider=Microsoft.Jet.OLEDB.4.0; Data Source=c:\\database\\testDB.mdb");
conDatabase.Open();
Dr = cmdDatabase.ExecuteReader();
{
string UserNameDB = Dr["USERID"].ToString();
string PasswordDB = Dr["PASSWORD"].ToString();
string userbranchDB = Dr["USERBRANCH"].ToString();
string userRoleDB = Dr["ROLE"].ToString();
if ((UserName == UserNameDB.TrimEnd().TrimStart()) & (Password == PasswordDB.TrimEnd().TrimStart()))
{
Session["loginm"] = strUserID;
Session["userBranch"] = userbranchDB;
Session["CaseIDClient"] = Dr["CASENO"].ToString();
boolReturnValue = true;
break;
}
}
conDatabase.Close();
Dr.Close();
return boolReturnValue;
}
protected void LoginButton_Click(object sender, EventArgs e)
{
}
Tuesday, November 18, 2008
simple search parsing string by Split Method C# ASP.NET
Simple search parsing string by Split Method C# ASP.NET.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="searchtest.aspx.cs" Inherits="searchtest" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" /></div>
</form>
</body>
</html>
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;
public partial class searchtest : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void Button1_Click(object sender, EventArgs e)
{
char[] delimiterChars = { ' ', ',', '.', ':', '\t' };
string text = TextBox1.Text;
string[] words = text.Split(delimiterChars);
Response.Write( words.Length);
foreach (string s11 in words)
{
Response.Write(s11.ToString()+"<br />");
}
}
}
Monday, November 17, 2008
Asp.net Access database for optional search criteria or Where Condition Code Sample
It similar to use COALESCE in access database, or passing null parameter to access database.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Text="Button" /><br />
<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="CASEID"
DataSourceID="AccessDataSource1">
<Columns>
<asp:BoundField DataField="CASEID" HeaderText="CASEID" InsertVisible="False" ReadOnly="True"
SortExpression="CASEID" />
<asp:BoundField DataField="CASEIDNO" HeaderText="CASEIDNO" SortExpression="CASEIDNO" />
<asp:BoundField DataField="SERVICEID" HeaderText="SERVICEID" SortExpression="SERVICEID" />
<asp:BoundField DataField="BANKNAME2" HeaderText="BANKNAME2" SortExpression="BANKNAME2" />
<asp:BoundField DataField="Days3Notice" HeaderText="Days3Notice" SortExpression="Days3Notice" />
<asp:BoundField DataField="SERVICEIDDESC" HeaderText="SERVICEIDDESC" SortExpression="SERVICEIDDESC" />
<asp:BoundField DataField="LOANNO" HeaderText="LOANNO" SortExpression="LOANNO" />
<asp:BoundField DataField="BRANCH" HeaderText="BRANCH" SortExpression="BRANCH" />
<asp:BoundField DataField="DTI" HeaderText="DTI" SortExpression="DTI" />
<asp:BoundField DataField="USERID" HeaderText="USERID" SortExpression="USERID" />
</Columns>
</asp:GridView>
<asp:AccessDataSource ID="AccessDataSource1" CancelSelectOnNullParameter="False"
runat="server" DataFile="C:\database\magestic.mdb"
SelectCommand="SELECT * FROM [CaseInfo] WHERE (@USERID IS NULL OR USERID LIKE '%' + @USERID + '%') and (@BRANCH IS NULL OR BRANCH LIKE '%' + @BRANCH + '%')" OnSelecting="AccessDataSource1_Selecting">
<SelectParameters>
<asp:ControlParameter ControlID="TextBox1" Name="USERID" PropertyName="Text" Type="String" />
<asp:ControlParameter ControlID="TextBox2" Name="BRANCH" PropertyName="Text" Type="String" />
</SelectParameters>
</asp:AccessDataSource>
</div>
</form>
</body>
</html>
code behind
using System;
using System.Data;
using System.Configuration;
using System.Collections;
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;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
protected void AccessDataSource1_Selecting(object sender, SqlDataSourceSelectingEventArgs e)
{
if (!IsPostBack)
{
e.Cancel = true;
}
}
}
Friday, November 14, 2008
C# Access Connection String live sample ASP.net
Create Rss Feed (Web service) using C# Asp.net Access database
Thursday, November 13, 2008
Retriving page name in program like Default.aspx, Home.aspx - asp.net
Request.Path.Substring(Request.Path.LastIndexOf("/") + 1)
Retrieving user Name on any page asp.net 2.0
using profile.UserName
JD Edwards - Sales Update Process - R42800
Wednesday, November 12, 2008
Rewrite url with Masterpage & Intelligencia.UrlRewriter.dll in asp.net 2.0
URL Rewriting Multiple Parameters using Asp.net 2.0 C#, web.config
URL Rewriting Multiple Parameters using Asp.net 2.0 C#, web.config
1> Download Intelligencia.UrlRewriter.dll copy to bin folder.
2> Create Web.config as following:
<?xml version="1.0"?>
<configuration>
<configSections>
<section name="rewriter"
requirePermission="false"
type="Intelligencia.UrlRewriter.Configuration.RewriterConfigurationSectionHandler, Intelligencia.UrlRewriter" />
</configSections>
<system.web>
<httpModules>
<add name="UrlRewriter" type="Intelligencia.UrlRewriter.RewriterHttpModule, Intelligencia.UrlRewriter"/>
</httpModules>
</system.web>
<rewriter>
<rewrite url="~/products/(.+).aspx" to="~/products.aspx?category=$1" />
<rewrite url="~/mainsearch/(.+)/(.+).aspx" to="~/mainsearch.aspx?URLID=$1&prdty=$2" />
</rewriter>
</configuration>
products page is for 1 parameter mainsearch is for 2 parameters.
Monday, November 10, 2008
Floatutorial: Tutorial 9 - all steps combined
Saturday, November 8, 2008
JD Edwards Convert Julian Date to Normal (Gregorian) Date vice versa
declare @rpdivj as int
declare @datea as datetime
set @rpdivj='102015'
set @datea= DATEADD(dy, @rpdivj % 1000, DATEADD(yy, @rpdivj / 1000,-1))
print DATEADD(dy, @rpdivj % 1000, DATEADD(yy, @rpdivj / 1000, -1))
print DATEPART(month, @datea)
print DATEPART(day, @datea)
print DATEPART(year, @datea)
--Julian Date to Normal Date
declare @y as varchar(10)
declare @dy as varchar(10)
declare @date1 as datetime
declare @szupmj as varchar(10)
set @date1= getdate()--'10/01/02'
-- set @date1= '10/1/2002'
set @y =(datepart(yy,@date1) - 1900) * 1000;
set @dy = datepart(dy,@date1);
set @szupmj = @y + cast(@dy as int);
print 'Date ====>>> '+ @szupmj
in Select Statement
DATEADD(dy, cast(SDTRDJ as varchar(10)) % 1000, DATEADD(yy, cast(SDTRDJ as varchar(10)) / 1000,-1))
select (datepart(yy,getdate()) - 1900) * 1000+ cast(datepart(dy,getdate())as int)
select CONVERT(CHAR(15),GETDATE(),101)
Thursday, November 6, 2008
Gridview with Checkbox Live sample
Wednesday, November 5, 2008
Tuesday, November 4, 2008
Cosmos - C# Open Source Managed Operating System.
Cosmos?
Cosmos is short for C# Open Source Managed Operating System. Despite C# being in the name, VB.NET, Fortran, and any .NET language can be used. We chose the C# title because our work is done in C#, and VBOSMOS just does not sound as nice.
Cosmos is not an Operating System in the traditional sense, but instead, it is an "Operating System Kit", or as I like to say "Operating System Legos", that allows you to create your own Operating System. However, having been down this path before, we wanted to make it easy to use and build. Most users can write and boot their own Operating System in just a few minutes, and using Visual Studio.
Cosmos lets Visual Studio compile your code to IL and then Cosmos compiles the IL into machine code.
Monday, October 27, 2008
Mass Email System Using Google Account and Email address from Access database.
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="sndgooglemail.aspx.cs" Inherits="sndgooglemail" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<table border="1" style="width: 80%">
<tr>
<td>
</td>
<td style=" text-align: center;">
<asp:Label ID="Label3" runat="server" Font-Bold="True" Text="Automatic Email System"
Width="224px"></asp:Label></td>
<td>
</td>
</tr>
<tr>
<td>
</td>
<td style=" text-align: left">
</td>
<td>
</td>
</tr>
<tr>
<td style=" text-align: right">
<asp:Label ID="Label1" runat="server" Text="Subject:"></asp:Label></td>
<td>
<asp:TextBox ID="TxtSubject" runat="server" Width="282px"></asp:TextBox></td>
<td>
</td>
</tr>
<tr>
<td style=" height: 246px; text-align: right">
<asp:Label ID="Label2" runat="server" Text="Message:"></asp:Label></td>
<td style=" height: 246px">
<asp:TextBox ID="Txtmsg" runat="server" Height="309px" TextMode="MultiLine"
Width="586px"></asp:TextBox>
</td>
<td style=" height: 246px">
</td>
</tr>
<tr>
<td>
</td>
<td>
<asp:Button ID="Button1" runat="server" Text="Send" OnClick="Button1_Click" />
<asp:Label ID="lblMsg" runat="server" Width="246px"></asp:Label></td>
<td>
</td>
</tr>
</table>
<br />
<br />
<br />
<br />
<br />
<br />
</div>
</form>
</body>
</html>
code Behind
using System;
using System.Data;
using System.Configuration;
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.Net;
using System.Net.Mail;
using System.Data.OleDb;
public partial class sndgooglemail : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string strcomp = Txtmsg.Text;
Session["Comment"] = strcomp;
string txtsub = TxtSubject.Text;
Session["txtSubject"] = txtsub.ToString();
}
void sendemail(String EmailAdd)
{
SmtpClient client = new SmtpClient();
client.DeliveryMethod = SmtpDeliveryMethod.Network;
client.EnableSsl = true;
client.Host = "smtp.gmail.com";
client.Port = 587;
// setup Smtp authentication
System.Net.NetworkCredential credentials = new System.Net.NetworkCredential("YourGmailID@gmail.com", "YourPassword");
client.UseDefaultCredentials = false;
client.Credentials = credentials;
MailMessage msg = new MailMessage();
msg.From = new MailAddress("YourGmailID@gmail.com");
//UserID
//msg.From = new MailAddress(UserID.Text);
msg.To.Add(new MailAddress(EmailAdd.ToString()));
msg.Subject = Session["txtSubject"].ToString();
msg.IsBodyHtml = true;
msg.Body = string.Format("<html><head></head><body><b>" + Session["Comment"].ToString() + "</b></body>");
try
{
client.Send(msg);
lblMsg.Text = "Message sent.";
}
catch (Exception ex)
{
// lblMsg.ForeColor = Color.Red;
lblMsg.Text = "Error occured while sending your message." + ex.Message;
}
}
protected void Button1_Click(object sender, EventArgs e)
{
if (TxtSubject.Text != "")
{
ReadDB();
}
else
lblMsg.Text = "Error Subject Blanks";
}
void ReadDB()
{
string connectionString = "provider=Microsoft.Jet.OLEDB.4.0;data source=c:\\database\\xxxxx.mdb";
OleDbConnection myOleDbConnection = new OleDbConnection(connectionString);
OleDbCommand myOleDbCommand = myOleDbConnection.CreateCommand();
string Strsql = "SELECT ID, EmailID FROM EmailAdd";
myOleDbCommand.CommandText = Strsql;
myOleDbConnection.Open();
OleDbDataReader myOleDbDataReader = myOleDbCommand.ExecuteReader();
myOleDbDataReader.Read();
while (myOleDbDataReader.Read())
{
sendemail(myOleDbDataReader["EmailID"].ToString());
}
}
}
Friday, October 24, 2008
Error System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from
Sending Email using Gmail Account live Sample
How to LOGIN at salesforce Apex Explorer 8.0
Password: Yourpassword+Security Token (passwordXXXXXXXXXX)
to get security token goto
http://trust.salesforce.com/trust/security/identity_feature.html
_________________________________________________________________
You live life beyond your PC. So now Windows goes beyond your PC.
http://clk.atdmt.com/MRT/go/115298556/direct/01/