• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 595
  • Last Modified:

Retrive Deleted Email Items from Outlook 2007 and 2010 with VB6

NOTE: Chris (craisin) was very helpful in getting me on the right track for the original question that resulted in the code I am listing below.

I have a program that will access MS Outlook from an email address in a text box.  It is working fine in 2010 for the Inbox, Personal Folders, and the Sent Items.  In 2007 it only retrieves data from the Personal Folders.

List below is the code for 2010

 Option Explicit
    '=== For accessing all correspondence for a specifice email address ==================
    Private oOutapp      As outlook.Application
    Private oNs          As outlook.NameSpace
    Private oMyinbox     As outlook.MAPIFolder
    Dim oMyExplorer      As outlook.Explorer
    '==========================================================================

Private Sub SeeEmailInfo_btn_Click()
 
    If Trim(EMail_txt.Text) = "" Then
        MsgBox "No email address assigned to this customer", vbOKOnly
        Exit Sub
    End If
   
    Set oOutapp = New outlook.Application
    Set oNs = oOutapp.GetNamespace("MAPI")
    Set oMyinbox = oNs.GetDefaultFolder(olFolderInbox)
    Set oMyExplorer = oMyinbox.GetExplorer
    oMyExplorer.Search EMail_txt.Text, olSearchScopeAllOutlookItems
    oMyExplorer.Display

End Sub

Any ideas on this would be very helpfull

Jack
0
JackVannoy
Asked:
JackVannoy
  • 3
1 Solution
 
JackVannoyAuthor Commented:
I have an open question that shows it was posted on 05/04/2011.  The question was a new question, with a new probolem,  that followed up on a question that was resolved and accepted.  the expert who provided the answer for the first queston was Chris (craisin)

Just curious about the lack of response to this question  I have not receieved and responses as of today 05/09/2011. Guess I want to know what I should do. I think I may have put in the wrong zone.  It should have been either Visual Basic Classic or Prog Language.

Jack
0
 
mbizupCommented:
Jack,

Including the Outlook and Microsoft Office zones in this question may have been helpful (I have added them, and the Visual Basic zone now).  Even though the programming language you are using is Visual Basic, the commands you are using are very specific to Outlook.  They would be familiar to anyone who does Outlook automation on a regular basis in any programming language, but not necessarily familiar to all Visual Basic programmers -- many of whom have never written Outlook programs.  The combination of VB, Outlook and Office initially would likely have gotten you a quick response.  

Also, the Request Attention button in the original post will alert the Moderators.  If a question goes for more than 24 hours without comments, you can use this button to ask the Moderators to try to get Experts involved.

Regarding the actual question, I think your trouble is in this line:

 oMyExplorer.Search EMail_txt.Text, olSearchScopeAllOutlookItems 

Open in new window


olSearchScopeAllOutlookItems is a constant available in Outlook 2010, but not in Outlook 2007.  Your code copied as written into Access VBA (Office 2007) caused a compile error.

You can find search scope constants for Outlook 2010 here:
http://msdn.microsoft.com/en-us/library/microsoft.office.interop.outlook.olsearchscope(v=office.14).aspx

The constants for 2007 can be seen by selecting Office 2007 from the 'Other Versions' drop down list at the top of the page.

Try using olSearchScopeAllFolders  instead:

oMyExplorer.Search EMail_txt.Text, olSearchScopeAllFolders  

Open in new window


0
 
JackVannoyAuthor Commented:
Thank you mbizup for your response and for reminding me of the (Request Attention) button.

I will give your post a try and respond as to the results.

Jack
0
 
JackVannoyAuthor Commented:
Thank you mbizup,

The program is working fine now.  I appreciate you giving me the last piece of the puzzle.

Jack
0

Featured Post

NFR key for Veeam Backup for Microsoft Office 365

Veeam is happy to provide a free NFR license (for 1 year, up to 10 users). This license allows for the non‑production use of Veeam Backup for Microsoft Office 365 in your home lab without any feature limitations.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now