I am accessing MS Outlook Folders through VB.NET console application through Command Line Arguments.The mails are displayed in HTML table format.
I am displaying all mails once at a time.I want to display it as page like first 10 items at once and rest 10 after clicking the link button "Next".
I am not getting any idea for tht?
Can anybody suggest me how can i do this?

this is the coading
for which i have done in windows application
it will display all the mails in the outlook inbox folder in to data grid view i had added reference of ms outlook 11.0 object library
here outlookdb is my sql data base name
and outlooktbl2 is my outlook table in which i am saving at a time
the whole things sender name, mail id , subject, body, attachment

Imports Outlook
Imports System.Reflection
Imports System.Runtime.InteropServices.Marshal
Imports System.Data
Imports System.Data.SqlClient
Imports System.Data.SqlClient.SqlConnection

Public Class Form2
Inherits System.Windows.Forms.Form
Dim oNs As Outlook.NameSpace
Dim oFldr As Outlook.MAPIFolder
Dim ds As New DataSet()
Dim connection As New SqlConnection
Dim command As New SqlCommand
Dim oMsg As Outlook.MailItem
Dim StrText As String
Dim strMessage As String
Dim strName As String

Private Sub Form2_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
'connection string
connection = New SqlConnection("server=SYSTEM-06\SQLEXPRESS;database=outlookdb;Integrated Security=true ")
command = New SqlCommand("select * from outlooktbl2", connection)
Dim oApp As Outlook.Application = New Outlook.Application
'' Get Mapi NameSpace.
Dim oNS As Outlook.NameSpace = oApp.GetNamespace("MAPI")
'' Get Messages collection of Inbox.
Dim oInbox As Outlook.MAPIFolder = oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
Dim oItems As Outlook.Items = oInbox.Items
'MessageBox.Show("Total : " & oItems.Count)
' Get unread e-mail messages.
Dim i As Integer
Dim iCtr As New Integer
'creating data table
Dim dt As New DataTable("inbox")
Dim dc2 As New DataColumn("S_no", GetType(Integer))
Dim dc3 As New DataColumn("SenderName", GetType(String))
Dim dc4 As New DataColumn("subject", GetType(String))
Dim dc5 As New DataColumn("ReceivedDate", GetType(DateTime))
Dim dc6 As New DataColumn("Attachment", GetType(String))
For i = 1 To oItems.Count
oMsg = oItems.Item(i)
Dim S_no() As String = {i}
Dim Sendernames() As String = {oMsg.SenderName}
Dim Subject() As String = {oMsg.Subject}
Dim theDate As DateTime = (oMsg.ReceivedTime)
Dim Body() As String = {oMsg.Body}
Dim AttachCnt As Integer = oMsg.Attachments.Count
Dim attachment As String = oMsg.Attachments.Class
MessageBox.Show("Attachments:" + AttachCnt.ToString())
' getting the name of the attachment
MessageBox.Show("attachment:" & StrText.ToString())
If AttachCnt > 0 Then
For iCtr = 1 To AttachCnt
strName = oMsg.Attachments.Item(iCtr).FileName
StrText = Mid(strName, Len(strName) - 3, Len(strName))
'MessageBox.Show("strname: " & strName)
MessageBox.Show("strtext:" & StrText.ToString())
End If
'adding rows in to the data table
For j As Integer = 0 To Sendernames.Length - 1
Dim dr As DataRow = dt.NewRow
dr("S_no") = i
dr("SenderName") = Sendernames(j)
dr("Subject") = Subject(j)
dr("ReceivedDate") = theDate
If (AttachCnt > 0) Then
dr("Attachment") = (strName.ToString())
dr("Attachment") = ("No Attachment")
End If
'adding rows to data table
'opening conn n insert contents of data grid in to outlooktbl2
command.Connection = connection
command.CommandText = "Insert into outlooktbl2(Sender,Subject,Date,Body,Attachname)values('" + Sendernames(j) + "','" + Subject(j) + "','" + theDate + "','" + Body(j) + " ','" + strName + "')"
'displaying the data table contents in to data grid view1
Dim ds As New DataSet()
ds = New DataSet()
'creating a dataset
'adding the table to dataset
Grid1.DataSource = dt
End Sub

Private Sub DataGrid1_Navigate(ByVal sender As System.Object, ByVal ne As System.Windows.Forms.NavigateEventArgs)
End Sub

Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click
Dim i As Integer
'To delete the selected row
i = Grid1.CurrentRow.Index

End Sub

This article has been dead for over six months. Start a new discussion instead.