Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. access to outlook inbox

access to outlook inbox

Scheduled Pinned Locked Moved Visual Basic
csharptutorialquestion
6 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    pnpfriend
    wrote on last edited by
    #1

    how can i access to inbox in outlook.. I have outlook 9.0 reference..in VB .NET I have create new folder call Temp to recieve and send email from my hotmail account... When I click InBox.. there were lots of mails inside.. and I want to access each message programmatically.. and I dont' really know how to do it.. I tried something like following.. Dim olApp As Outlook.Application olApp = new Outlook.Application Dim fldMain As Outlook.Folders fldMain = gnspNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox) thatnks

    D 1 Reply Last reply
    0
    • P pnpfriend

      how can i access to inbox in outlook.. I have outlook 9.0 reference..in VB .NET I have create new folder call Temp to recieve and send email from my hotmail account... When I click InBox.. there were lots of mails inside.. and I want to access each message programmatically.. and I dont' really know how to do it.. I tried something like following.. Dim olApp As Outlook.Application olApp = new Outlook.Application Dim fldMain As Outlook.Folders fldMain = gnspNameSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox) thatnks

      D Offline
      D Offline
      Dave Kreskowiak
      wrote on last edited by
      #2

      GetDefaultFolder returns a MAPIFolder object. This has an Items property which will allow you to access the emails in the folder. Check out the docs on the MAPIFolder object here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaol10/html/olobjMAPIFolder.asp[^] RageInTheMachine9532

      P 1 Reply Last reply
      0
      • D Dave Kreskowiak

        GetDefaultFolder returns a MAPIFolder object. This has an Items property which will allow you to access the emails in the folder. Check out the docs on the MAPIFolder object here: http://msdn.microsoft.com/library/default.asp?url=/library/en-us/vbaol10/html/olobjMAPIFolder.asp[^] RageInTheMachine9532

        P Offline
        P Offline
        pnpfriend
        wrote on last edited by
        #3

        I have following code, but folder.items is not a collection object so it gives me error. I'm using VB .Net not VB 6.0 Dim olApp As Outlook.Application olApp = New Outlook.Application Dim mail As Outlook.MailItem Dim nSpace As Outlook.NameSpace Dim folder As Outlook.MAPIFolder Dim eInfo As emailInformation nSpace = olApp.GetNamespace("MAPI") folder = nSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox) For Each mail In folder.Items eInfo.theBody = mail.Body() eInfo.theCC = mail.CC eInfo.theFrom = mail.SenderName eInfo.theTo = mail.ReceivedByName eInfo.theDate = "12/13/4" eInfo.theSubject = mail.Subject eInfo.wayToPrint = 1 PrintEmail(eInfo) Next

        D 1 Reply Last reply
        0
        • P pnpfriend

          I have following code, but folder.items is not a collection object so it gives me error. I'm using VB .Net not VB 6.0 Dim olApp As Outlook.Application olApp = New Outlook.Application Dim mail As Outlook.MailItem Dim nSpace As Outlook.NameSpace Dim folder As Outlook.MAPIFolder Dim eInfo As emailInformation nSpace = olApp.GetNamespace("MAPI") folder = nSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox) For Each mail In folder.Items eInfo.theBody = mail.Body() eInfo.theCC = mail.CC eInfo.theFrom = mail.SenderName eInfo.theTo = mail.ReceivedByName eInfo.theDate = "12/13/4" eInfo.theSubject = mail.Subject eInfo.wayToPrint = 1 PrintEmail(eInfo) Next

          D Offline
          D Offline
          Dave Kreskowiak
          wrote on last edited by
          #4

          Opps! My bad! Following the docs for MAPIFolder and MailItems you must use the built in Iterator Methods of the MAPIFolder. These of GetFirst(), GetNext(), GetLast(), and GetPrevious().

              Dim olApp As New Outlook.Application
              Dim mailItem As Outlook.MailItem
          
              Dim nSpace As Outlook.NameSpace
              Dim ibFolder As Outlook.MAPIFolder
          
              nSpace = olApp.GetNamespace("MAPI")
              ibFolder = nSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox)
          
              Debug.WriteLine("Number of messages in folder " & ibFolder.Name & ": " & ibFolder.Items.Count)
              mailItem = ibFolder.Items.GetFirst()
              While (Not mailItem Is Nothing)
                  Debug.WriteLine("Message Header: " & mailItem.Subject)
                  mailItem = ibFolder.Items.GetNext()
              End While
          

          Microsoft didn't do the greatest job in the world with the documentation on the Office Object Models... RageInTheMachine9532

          P 2 Replies Last reply
          0
          • D Dave Kreskowiak

            Opps! My bad! Following the docs for MAPIFolder and MailItems you must use the built in Iterator Methods of the MAPIFolder. These of GetFirst(), GetNext(), GetLast(), and GetPrevious().

                Dim olApp As New Outlook.Application
                Dim mailItem As Outlook.MailItem
            
                Dim nSpace As Outlook.NameSpace
                Dim ibFolder As Outlook.MAPIFolder
            
                nSpace = olApp.GetNamespace("MAPI")
                ibFolder = nSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox)
            
                Debug.WriteLine("Number of messages in folder " & ibFolder.Name & ": " & ibFolder.Items.Count)
                mailItem = ibFolder.Items.GetFirst()
                While (Not mailItem Is Nothing)
                    Debug.WriteLine("Message Header: " & mailItem.Subject)
                    mailItem = ibFolder.Items.GetNext()
                End While
            

            Microsoft didn't do the greatest job in the world with the documentation on the Office Object Models... RageInTheMachine9532

            P Offline
            P Offline
            pnpfriend
            wrote on last edited by
            #5

            thank you very much RageIn...

            1 Reply Last reply
            0
            • D Dave Kreskowiak

              Opps! My bad! Following the docs for MAPIFolder and MailItems you must use the built in Iterator Methods of the MAPIFolder. These of GetFirst(), GetNext(), GetLast(), and GetPrevious().

                  Dim olApp As New Outlook.Application
                  Dim mailItem As Outlook.MailItem
              
                  Dim nSpace As Outlook.NameSpace
                  Dim ibFolder As Outlook.MAPIFolder
              
                  nSpace = olApp.GetNamespace("MAPI")
                  ibFolder = nSpace.GetDefaultFolder(OlDefaultFolders.olFolderInbox)
              
                  Debug.WriteLine("Number of messages in folder " & ibFolder.Name & ": " & ibFolder.Items.Count)
                  mailItem = ibFolder.Items.GetFirst()
                  While (Not mailItem Is Nothing)
                      Debug.WriteLine("Message Header: " & mailItem.Subject)
                      mailItem = ibFolder.Items.GetNext()
                  End While
              

              Microsoft didn't do the greatest job in the world with the documentation on the Office Object Models... RageInTheMachine9532

              P Offline
              P Offline
              pnpfriend
              wrote on last edited by
              #6

              Hi.. I have the following code Dim ie As New SHDocVw.InternetExplorer ie = CreateObject("InternetExplorer.Application") With ie .Visible = False .Navigate("c:\OutLookStyle.html") .ExecWB(SHDocVw.OLECMDID.OLECMDID_PRINT, SHDocVw.OLECMDEXECOPT.OLECMDEXECOPT_DONTPROMPTUSER) 'printing the file without showing the print dialog System.Threading.Thread.Sleep(5000) 'pausing the application to finish printing End With ie.Quit() But i'm getting the following error whenever the project execute .ExecWB(....) An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in emailPrint.exe Additional information: Trying to revoke a drop target that has not been registered (OR) An error has occurred in the script o this page Line: 288 Char: 1 Error: 'dialogArguments.__IE_PrintType' is null or not an object Code: 0 URL: res://c:\\windows\system32\shdoclc.dll/priview.dlg Do you want to continue running scripts on this page? Yes/No? But I have no problem or whatsoever, if I debug and put a breakline on .ExecWB(..). the html page get printed without showing printdialog as I excepted. If I dont have a breakline at .ExecWB(..) then I got either or both of above errors( in red ) what would be the reason of getting such errors? and How can i print the web page to printer without showing PrintDialog???

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups