Hi
I use the code below to select an email in my inbox and carry out various tasks with it. At present I choose the email I want to work with by "ticking" it as "Complete" and then running the code from a button in a form. The code works by checking each email in turn and using the one with "FlagStatus = olFlagComplete". My query is, is there a way of using code to simply choose the email which is highlighted in my inbox rather than using the "Complete" flag (as other users of my database use this flag to manage their emails). Basically I need something to replace the "If temp.Items(I).FlagStatus = olFlagComplete" statement. I tried using things like "If temp.Items(I).IsSelected = TRUE", and also using color categories but they didn't work. Any help would be greatly appreciated.
Many thanks
AL
I use the code below to select an email in my inbox and carry out various tasks with it. At present I choose the email I want to work with by "ticking" it as "Complete" and then running the code from a button in a form. The code works by checking each email in turn and using the one with "FlagStatus = olFlagComplete". My query is, is there a way of using code to simply choose the email which is highlighted in my inbox rather than using the "Complete" flag (as other users of my database use this flag to manage their emails). Basically I need something to replace the "If temp.Items(I).FlagStatus = olFlagComplete" statement. I tried using things like "If temp.Items(I).IsSelected = TRUE", and also using color categories but they didn't work. Any help would be greatly appreciated.
Many thanks
AL
Code:
Dim ns As Outlook.Namespace
Dim sent As Outlook.MAPIFolder
Dim temp As Outlook.MAPIFolder
Dim I As Integer
Dim J As Integer
Dim email As MailItem
Dim att As Attachment
Dim emailname As String
Set ns = GetNamespace("MAPI")
Set temp = ns.GetDefaultFolder(olFolderInbox)
For I = temp.Items.Count To 1 Step -1
If temp.Items(I).Class <> 43 Then GoTo nexti:
If temp.Items(I).FlagStatus = olFlagComplete Then
'etc.