Results 1 to 2 of 2

Thread: Concatenating unread Outlook mails in a textbox

  1. #1

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354

    Concatenating unread Outlook mails in a textbox

    I have some code that grabs any unread emails from Outlook and displays them in a message box one at a time. However, I am trying to bring them into a multi line textbox.

    Here is the code. If I unmark the 'TextBox1.Text = strMess I only get the last message but the MsgBox(strMess) gives me each message sequentially. What am I doing wrong?
    VB Code:
    1. Dim oApp As Outlook.Application = _
    2.             New Outlook.Application
    3.         Dim sClassComp = "IPM.Note"
    4.         Dim oNS As Outlook.NameSpace = _
    5.             oApp.GetNamespace("MAPI")
    6.         Dim oInbox As Outlook.MAPIFolder = _
    7.             oNS.GetDefaultFolder(Outlook.OlDefaultFolders.olFolderInbox)
    8.         Dim oItems As Outlook.Items = oInbox.Items
    9.  
    10.         oItems = oItems.Restrict("[Unread] = true")
    11.  
    12.         Dim oMsg As Outlook.MailItem
    13.         Dim i As Integer
    14.         Dim strMess As String
    15.  
    16.         For i = 1 To oItems.Count
    17.             If oItems.Item(i).MessageClass = sClassComp Then
    18.                 oMsg = oItems.Item(i)
    19.                 strMess = "Message #" & (i) & vbNewLine & _
    20.                 (oMsg.SenderName) & vbNewLine & _
    21.                 (oMsg.Subject) & vbNewLine & _
    22.                 (oMsg.ReceivedTime) & vbNewLine & _
    23.                 (oMsg.Body) & vbNewLine
    24.                 'TextBox1.Text = strMess
    25.                 MsgBox(strMess)
    26.             End If
    27.         Next
    28.         oApp = Nothing
    29.         oNS = Nothing
    30.         oItems = Nothing
    31.         oMsg = Nothing

  2. #2

    Thread Starter
    Hyperactive Member
    Join Date
    Apr 2003
    Location
    Three Rivers, MI
    Posts
    354
    ^^ Bump ^^

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width