PDA

View Full Version : Outlook - Display unread emails



Silverfish
09-07-2011, 04:46 PM
Here's what I've got so far:
Public Sub Label1_Click()

Set otlkApp = CreateObject("Outlook.Application")
Set MAPISpace = otlkApp.GetNamespace("MAPI")
Set oFolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).folders("Negative Feedback")

Dim currentItem As MailItem

For Each MailItem In oFolder.Items

If MailItem.UnRead Then
Label1.Caption = "Subject: " & MailItem.Subject & vbCrLf & vbCrLf & "Body: " & MailItem.Body
Set currentItem = MailItem
End If
Next MailItem

End Sub

Private Sub BtnCondition_Click()
Open "C:\Users\Jeff\Desktop\Work Shortcuts\Hotkey Responses\NFB_Condition.txt" For Output As #1
record = Label1.Caption
Print #1, record
Close #1

Set otlkApp = CreateObject("Outlook.Application")
Set MAPISpace = otlkApp.GetNamespace("MAPI")
Set oFolder = Application.GetNamespace("MAPI").GetDefaultFolder(olFolderInbox).folders("Negative Feedback")

If MailItem = Label1.Caption Then
currentItem.UnRead = False
currentItem.Save
End If

End Sub

What I'm hung up on is associating the email that is displayed(in the label) with the button click. Any suggestions?