getting olMailItem from outlook Table

J

josephine

managed to filter Inbox Folder to get only relevant mails.
now i need to get e-mail's body

?question:
how do i get a MailItem into oM representd by a row in oTable???

Imports system
Imports System.IO
Imports System.Windows.Forms
Imports System.Xml
Imports outlook = Microsoft.Office.Interop.Outlook


Public Class frmMain

Private Sub frmMain_Load(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Load

Dim objOutlook As Microsoft.Office.Interop.Outlook.Application
Dim oM As Microsoft.Office.Interop.Outlook.MailItem
objOutlook = New Microsoft.Office.Interop.Outlook.Application
Dim oNS As Microsoft.Office.Interop.Outlook.NameSpace
oNS = objOutlook.GetNamespace("mapi")
Dim oFolder As Microsoft.Office.Interop.Outlook.MAPIFolder
oFolder =
oNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox)
Dim filter As String = "[subject]=SCMB Securities Lending extract
AND [unread]=true "
Dim oTable As Microsoft.Office.Interop.Outlook.Table
Try
oTable =
oNS.GetDefaultFolder(Microsoft.Office.Interop.Outlook.OlDefaultFolders.olFolderInbox).GetTable(filter)
Catch ex As Exception
MsgBox(ex.Message)
End Try
MsgBox(oTable.GetRowCount)
Do Until oTable.EndOfTable
oM = oTable.FindNextRow
MsgBox(oM.HTMLBody)
Loop
objOutlook.Quit()
objOutlook = Nothing
GC.Collect()
End Sub

End Class
 
E

Eric Legault [MVP - Outlook]

You need to use additional calls to get a MailItem explicitly so you can edit
it by using the EntryID to get a handle to the item:

(VBA example)

objTable.Columns.RemoveAll
objTable.Columns.Add ("EntryID")

Do While objTable.EndOfTable = False
Set objRow = objTable.GetNextRow
Set objItem = Session.GetItemFromID(objRow.Item(1))
objItem.UnRead = False
Loop
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top