In this blog, learn how to import gmail data (email id from gmail) in ASP.NET. You must provide a gmail account (user id and password) to authenticate. The code uses Google Data API.
Step 1: Download the latest version of Google_Data_API_Setup_2.1.0.0.msi and install to your machine from
https://code.google.com/p/google-gdata/downloads/list. Make sure the find the right location and version of the msi. The location of the download may have moved.
Step 2: Create a Web Application in Visual Studio and design a page. Here is my .aspx page look like.
- <%@ Page Language="C#" AutoEventWireup="true" CodeFile="import_gmail.aspx.cs" Inherits="import_gmail" %>
- <!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 id="Head1" runat="server">
- <title></title>
- <style type="text/css">
- .style1
- {
- width: 100%;
- }
- </style>
- </head>
- <body>
- <form id="form1" runat="server">
- <div style="height: 100px; background-color: #808080">
- </div>
- <div align="center">
- <table class="style1">
- <tr>
- <td>
- </td>
- <td>
- </td>
- <td>
- </td>
- <td>
- </td>
- </tr>
- <tr>
- <td>
- </td>
- <td>
- Enter your Gmail id</td>
- <td>
- <asp:TextBox ID="txt_email" runat="server" Width="250px"></asp:TextBox>
- <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
- ControlToValidate="txt_email" ErrorMessage="*"></asp:RequiredFieldValidator>
- </td>
- <td>
- </td>
- </tr>
- <tr>
- <td>
- </td>
- <td>
- Enter your Gmail Password</td>
- <td>
- <asp:TextBox ID="txtpass" runat="server" TextMode="Password" Width="250px"></asp:TextBox>
- <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server"
- ControlToValidate="txtpass" ErrorMessage="*"></asp:RequiredFieldValidator>
- </td>
- <td>
- </td>
- </tr>
- <tr>
- <td>
- </td>
- <td align="right">
- <asp:Button ID="Button1" runat="server" onclick="Button1_Click"
- Text="Get List" />
- </td>
- <td>
- <asp:Label ID="lbl_email_count" runat="server" Text="Label"></asp:Label>
- </td>
- <td>
- </td>
- </tr>
- <tr>
- <td>
- </td>
- <td>
- </td>
- <td>
- <asp:GridView ID="GV_List" runat="server" EnableModelValidation="True"
- PageSize="25" AutoGenerateColumns="False">
- <Columns>
- <asp:BoundField DataField="emailid" HeaderText="Email List" />
- </Columns>
- </asp:GridView>
- </td>
- <td>
- </td>
- </tr>
- <tr>
- <td>
- </td>
- <td>
- </td>
- <td>
- </td>
- <td>
- </td>
- </tr>
- <tr>
- <td>
- </td>
- <td>
- </td>
- <td>
- </td>
- <td>
- </td>
- </tr>
- </table>
- </div>
- </form>
- </body>
- </html>

Pankajkumar PatelPosted Sep 9, 2019, 11:14 PM
Nice article
kalu singh raoPosted Nov 26, 2015, 5:43 AM
good one
aditya immadiPosted May 22, 2013, 10:18 AM
Error 2 Make sure that the class defined in this code file matches the 'inherits' attribute, and that it extends the correct base class (e.g. Page or UserControl). ...i got dis error can u fix it thanks