Monday, October 27, 2008

Mass Email System Using Google Account and Email address from Access database.

Mass Email System Using Google Account and Email address from Access database.
 
Getting email ids from access database, using google smtp to send message. 

<%@ 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>
                    &nbsp;
                </td>
                <td style=" text-align: center;">
                    &nbsp;<asp:Label ID="Label3" runat="server" Font-Bold="True" Text="Automatic Email System"
                        Width="224px"></asp:Label></td>
                <td>
                </td>
            </tr>
            <tr>
                <td>
                    &nbsp;
                </td>
                <td style=" text-align: left">
                    &nbsp; &nbsp;
                </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>
                    &nbsp;
                </td>
                <td>
                    &nbsp;<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>
        &nbsp;<br />
        &nbsp;<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());
        }
    }
}

Developing a Shopping Cart in ASP.NET

Developing a Shopping Cart in ASP.NET

Friday, October 24, 2008

Error System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from

Error System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from

Add following code in your web.config to fix this error

<configuration>
  <system.web>
     <pages validateRequest="false" />
  </system.web>
</configuration>

Sending Email using Gmail Account live Sample

<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        &nbsp;<asp:TextBox ID="Txtmsg" runat="server" Height="231px" TextMode="MultiLine"
            Width="422px"></asp:TextBox><br />
        <asp:Label ID="lblMsg" runat="server" Width="362px"></asp:Label>
        <asp:Button ID="Button1" runat="server" Text="Button" OnClick="Button1_Click" /></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;


public partial class sndgooglemail : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        
    }


    protected void Button1_Click(object sender, EventArgs e)
    {
        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("youruser@gmail.com", "Password");
        client.UseDefaultCredentials = false;
        client.Credentials = credentials;

        MailMessage msg = new MailMessage();
        msg.From = new MailAddress("youruser@gmail.com");
        msg.To.Add(new MailAddress("tomail@xxxx.com"));
        msg.To.Add(new MailAddress("to2@xxxxx.com"));
        msg.To.Add(new MailAddress("aaaaa@gmail.com"));

        msg.Subject = "This is a test Email subject";
        msg.IsBodyHtml = true;
        msg.Body = string.Format("<html><head></head><body><b>" + Txtmsg.Text + "Test HTML Email</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;
        }

    }
}

How to LOGIN at salesforce Apex Explorer 8.0

User Name: Youremail(abc@hotmail.com)
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/

Tuesday, October 21, 2008

Get Time only C# asp.net from table

   DateTime eventime = DateTime.Parse(myOleDbDataReader["EVENTZTIME"].ToString());
  string evnttime = eventime.ToLongTimeString();

Multiple parameters datalist asp:HyperLink C# Asp.net

 <asp:DataList ID="DataList1" runat="server" DataSourceID="AccessDataSource2" RepeatColumns="4">
    <ItemTemplate>
     
     
    <asp:HyperLink Runat =server NavigateUrl ='<%#"stubhub4.aspx?STATE=" + DataBinder.Eval(Container.DataItem, "STATE").ToString()+"&REGION="+ DataBinder.Eval(Container.DataItem, "CITY").ToString()%>' ID="Hyperlink1"> 
    
    <%#DataBinder.Eval(Container.DataItem, "GENREGRANDPARENT")%> 
 
     </asp:HyperLink> 
 
    </ItemTemplate>
    </asp:DataList>

Date , day , month year in Sql-server and asp.net c#

Date , day , month year in Sql-server and asp.net c#
sql-server
select DATEPART(yyyy, getdate())
select DATEPART(dd, getdate())
select DATEPART(mm, getdate())
select convert(varchar,getdate(),101)
int streventday = DateTime.Now.Day;
int streventmnt = DateTime.Now.Month;
int streventyear = DateTime.Now.Year;
string strdate DateTime.Now.ToString("MM/dd/yyyy");


HyperLinkField Multiple parameter

<asp:HyperLinkField DataNavigateUrlFields="Type, MyParam2, MyParam3"DataNavigateUrlFormatString="Order_Details.aspx?MyParameter={0}&param2={1}&param3={2}"

HeaderText="Details" Text="Details" />

Sunday, October 19, 2008

Wednesday, October 15, 2008

Send emails in ASP.NET using Gmail credential

CodeProject: Send emails in ASP.NET using Gmail credentials. Free source code and programming help
As ASP.NET web developers, we often have to include an email sending module in our websites. When I was completing my third year project in the university, I had the same requirement in my web project. I had to go through so many web sites and blogs to find a solution. Using the class file included with this article, you can send emails by entering your Gmail account credentials.

Saturday, October 11, 2008

Windows Desktop Sharing with RDP in Vista

CodeProject: Windows Desktop Sharing with RDP in Vista: Add a Professional Interactive Help System to your Applications. Free source code and programming help: "Windows Desktop Sharing with RDP in Vista: Add a Professional Interactive Help System to your Applications"

Windows Vista introduced a powerful Remote Desktop Management API which is relatively unknown. This article will present an easy way to use it, in order to provide professional level help in your Vista applications.

Friday, October 10, 2008

Fully Editable GridView in ASP.NET 2 using C#

Fully Editable GridView in ASP.NET 2 using C#


This article describes how I made a fully editable gridview in C# using ASP.NET 2. The idea is that the GridView looks and works like an Excel spreadsheet. You see all the cells in the table, and you can edit any of the cells you like, and they are automatically updated (i.e. saved to the database). This is very often how people expect data tables to work in web pages, and I've often seen people clicking in vain on un-editable gridview cells, somehow expecting to edit them, and not understanding that they need to click an Edit button at the end of the row.

note:"Tested code"

Dynamic Sql-server Table name as a variable


Create procedure s_ProcTable
@TableName varchar(128)
as

declare @sql varchar(4000)
select @sql = 'select * from [' + @TableName + ']'
exec (@sql)
go
s_ProcTable 'Your Proc Name'

Tuesday, October 7, 2008

Insert Add Dynamically Menu Items C# asp.net

MenuItemCollection.AddAt Method (System.Web.UI.WebControls)

Inserts the specified MenuItem object in the current MenuItemCollection object at the specified index location.

Deploying ASP.NET Applications

Deploying ASP.NET Applications: "Deploying ASP.NET Applications"
After creating and testing your ASP.NET application, the next step is to deploy the application. Deployment is the process of distributing the finished application to be installed on other computer. We can use the built-in deployment feature that comes with Visual studio .NET to create a Windows Installer file - a .msi file for the purpose of deploying applications.

CodeProject: ColorPicker - ColorPicker with a compact footprint (VB.NET). Free source code and programming help

CodeProject: ColorPicker - ColorPicker with a compact footprint (VB.NET). Free source code and programming help
color picker... isn't there a bunch of those out there already? Yeah, but not really what I needed. There are some cool ones out there, but they were either too big, or too limited. Besides, I enjoy the challenge. What I wanted was to be able to easily select a color from a color gradient bar and adjust the brightness and saturation (HSB).

Sunday, October 5, 2008

Maximum numbers of rows in MS access

Maximum numbers of rows in MS access

---It's not the number of rows (records) that matter, it's the amount of torage capacity. Database (.mdb) file size 1 gigabyte.
However, because your database can include linked tables in other files, its total size is limited only by available storage capacity

----Database (.mdb) file size 1 gigabyte.
However, because your database can include linked tables in other files, its total size is limited only by available storage capacity.

Thursday, October 2, 2008

Web Slices

Web Slices

This section offers conceptual overview material for Web Slices, introduced with Windows Internet Explorer 8. A Web Slice uses simple HTML markup to represent a clipping of a Web page, enabling users to subscribe to content directly within a Web page.

Subscribing to Content with Web Slices

Today, many Web sites provide content updates through Really Simple Syndication (RSS) news feeds. This requires a Web site to duplicate some content as a special XML file, called a feed, that a news reader application can download and check for updates. In contrast, a Web Slice enables users to subscribe to content directly within a Web page; a separate feed file is not required. Users monitor content changes and view the updated portion of the Web page directly from the Favorites bar (the improved Links toolbar) of Internet Explorer.

Web Slice Format Specification - Version 0.9

A Web Slice allows users to subscribe to a portion of a Web page. The Web Slice format consists of the minimum HTML annotations necessary to enable the publication and consumption of a mutable item on a Web page. Web publishers can use this format in conjunction with properties from hAtom Microformat World Wide Web link to make portions of a Web page subscribe-able.

http://msdn.microsoft.com/en-us/library/cc956158(VS.85).aspx




 




Wednesday, October 1, 2008

SQL Server Locks

 
Use sp_who and sp_who2  to identify which processes may be blocking other processes.
 
 
You can override how SQL Server performs locking on a table by using the SP_INDEXOPTION command. Below is an example of code you can run to tell SQL Server to use page locking, not row locks, for a specific table:
 
SP_INDEXOPTION 'table_name', 'AllowRowLocks', FALSE
GO
SP_INDEXOPTION 'table_name', 'AllowPageLocks', FALSE
GO



See how Windows Mobile brings your life together—at home, work, or on the go. See Now