•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the VB.NET section within the Software Development category of DaniWeb, a massive community of 397,810 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,529 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our VB.NET advertiser:
Views: 5116 | Replies: 1
![]() |
•
•
Join Date: Sep 2006
Posts: 104
Reputation:
Rep Power: 2
Solved Threads: 0
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?
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?
•
•
Join Date: Apr 2007
Location: chennai
Posts: 3
Reputation:
Rep Power: 0
Solved Threads: 0
hi
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
PublicClass 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))
dt.Columns.Add(dc2)
dt.Columns.Add(dc3)
dt.Columns.Add(dc4)
dt.Columns.Add(dc5)
dt.Columns.Add(dc6)
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))
Next
'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())
Else
dr("Attachment") = ("No Attachment")
End If
'adding rows to data table
dt.Rows.Add(dr)
'opening conn n insert contents of data grid in to outlooktbl2
command.Connection = connection
connection.Open()
command.CommandText = "Insert into outlooktbl2(Sender,Subject,Date,Body,Attachname)values('" + Sendernames(j) + "','" + Subject(j) + "','" + theDate + "','" + Body(j) + " ','" + strName + "')"
command.ExecuteNonQuery()
Next
'displaying the data table contents in to data grid view1
Dim ds As New DataSet()
ds = New DataSet()
'creating a dataset
ds.Tables.Add()
'adding the table to dataset
Grid1.DataSource = dt
connection.Close()
Next
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
Grid1.Rows.RemoveAt(i)
End Sub
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
PublicClass 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))
dt.Columns.Add(dc2)
dt.Columns.Add(dc3)
dt.Columns.Add(dc4)
dt.Columns.Add(dc5)
dt.Columns.Add(dc6)
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))
Next
'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())
Else
dr("Attachment") = ("No Attachment")
End If
'adding rows to data table
dt.Rows.Add(dr)
'opening conn n insert contents of data grid in to outlooktbl2
command.Connection = connection
connection.Open()
command.CommandText = "Insert into outlooktbl2(Sender,Subject,Date,Body,Attachname)values('" + Sendernames(j) + "','" + Subject(j) + "','" + theDate + "','" + Body(j) + " ','" + strName + "')"
command.ExecuteNonQuery()
Next
'displaying the data table contents in to data grid view1
Dim ds As New DataSet()
ds = New DataSet()
'creating a dataset
ds.Tables.Add()
'adding the table to dataset
Grid1.DataSource = dt
connection.Close()
Next
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
Grid1.Rows.RemoveAt(i)
End Sub
![]() |
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
•
•
•
•
•
•
•
•
DaniWeb VB.NET Marketplace
•
•
•
•
.net .net framework 3.0 access asp code combo css custom data design development div dreamweaver dropdownlist firefox google checkout google checkout vat gpt guid partition table html html api javascript microsoft module navigation net news partition research reuse skin survey symantec tables theme w3c web windows workflow wysiwyg xml
- How to change the color of selected row of an HTML table without using CSS or Javascr (VB.NET)
- cfgrid inside an HTML table... possible? (ColdFusion)
- Generate Html from VB.net (ASP.NET)
- HTML table vertical aligning problem (HTML and CSS)
- problem in VB.NET? (VB.NET)
- html table to .csv (HTML and CSS)
- Need help with HTMl Table echoing? (PHP)
Other Threads in the VB.NET Forum
- Previous Thread: Help with data grid please
- Next Thread: Can somebody can tell what I am doing wrong!


Linear Mode