Results 1 to 3 of 3

Thread: Automation of receiving mail using OLE?

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    4

    Question

    Dear all,

    Thank to automating Outlook with OLE by Steve Anderson, could anyone tell me if it is possible to automate receiving mail using Outlook? I have studied the codes provided by Steve. However, there is no similar methods for me to get the mail from the inbox instead.

    Thank you very much in advance.

    Best regards,

    Ivan

  2. #2
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844
    Code:
    'read MS Outlook Inbox
    'uses Outlook  8/9 Object Model
    Sub ReadFolder()
        
        Dim objOL As Outlook.Application
        Dim objNS As Outlook.NameSpace
        Dim objFolder As Outlook.MAPIFolder
        Dim objMail As Outlook.MailItem
        Dim intItemCount As Integer
        
        'create objects, get mapi
        Set objOL = New Outlook.Application
        Set objNS = objOL.GetNamespace("MAPI")
        
        'get inbox
        Set objFolder = objNS.GetDefaultFolder(olFolderInbox)
        
        'loop thru inbox, display items
        For intItemCount = 1 To objFolder.Items.Count
            Set objMail = objFolder.Items.Item(intItemCount)
            Debug.Print objMail.SenderName & ": " & objMail.Subject
        Next intItemCount
        
        'cleanup
        Set objFolder = Nothing
        Set objMail = Nothing
        Set objNS = Nothing
        Set objOL = Nothing
        
    End Sub

  3. #3

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    4

    Question Any difference between Outlook Express and Outlook?

    Dear all,

    Thank you very much for your help. However, I have tried using the same code for Outlook Express but it failed. Could anyone help me on it? Thank you very much for your assistance in advance.

    Best regards,

    Ivan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width