Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here


Working with a selected email in Outlook

Working with a selected email in Outlook

Working with a selected email in Outlook


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



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

RE: Working with a selected email in Outlook

To get the currently selected e-mail, all you need to do is ...


Dim oOutlook As Outlook.Application Dim email As Outlook.MailItem Set oOutlook = New Outlook.Application Set email = oOutlook.ActiveExplorer.Selection(1)


We want to help you; help us to do it by reading this: Before you ask a question.

I'm working (slowly) on my own website

RE: Working with a selected email in Outlook

Many thanks Tony. Works a treat. Much appreciated.


Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members!

Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close