Results 1 to 6 of 6

Thread: VB to access Outlook Object Library

  1. #1

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    4

    Post

    Can someone help me Urgent!

    I need to write a Visual Basic program in VB5 to use the Outlook Object LIbrary to access the faxes, mails in Outlook 2000

    I would need to extract the attachments that comes with the individual mail.

    and delete away the mail from Outlook 2000.

    There is no exchange server involved.

    I need the sample program urgently, please email [email protected] if you know the soln.

  2. #2
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    you could do worse than have a look at:

    http://www.vb-world.net/demos/autoemail/
    Mark
    -------------------

  3. #3

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    4
    What does this program do ?

    I do not need to auto mail? I just need to be able to extract the attachements that's all.

    Originally posted by Mark Sreeves
    you could do worse than have a look at:

    http://www.vb-world.net/demos/autoemail/

  4. #4
    Frenzied Member Mark Sreeves's Avatar
    Join Date
    Nov 1999
    Location
    UK
    Posts
    1,845
    Code:
    Sub ReadEmail()
    Dim oApp As Outlook.Application
    Dim oNameSpace As Outlook.NameSpace
    Dim oFolder As Outlook.MAPIFolder
    Dim oMailItem As Object
    Dim sMessage As String
    Set oApp = New Outlook.Application
    Set oNameSpace = oApp.GetNamespace("MAPI")
    
    oNameSpace.Logon "MyProfile", , False, True
    
    Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
    
    For Each oMailItem In oFolder.Items
      With oMailItem
        
        If oMailItem.UnRead = True Then
        
        If oMailItem.Attachments.Count > 0 Then
          oMailItem.Attachments.Item(1).SaveAsFile "C:\Temp\OutlookAttachments\" & _
          oMailItem.Attachments.Item(1).Filename
       End If
      
       End If
    End With
    Next oMailItem
    Set oMailItem = Nothing
    Set oFolder = Nothing
    Set oNameSpace = Nothing
    Set oApp = Nothing
    End Sub
    Mark
    -------------------

  5. #5

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    4
    Originally posted by Mark Sreeves
    Code:
    Sub ReadEmail()
    Dim oApp As Outlook.Application
    Dim oNameSpace As Outlook.NameSpace
    Dim oFolder As Outlook.MAPIFolder
    Dim oMailItem As Object
    Dim sMessage As String
    Set oApp = New Outlook.Application
    Set oNameSpace = oApp.GetNamespace("MAPI")
    
    oNameSpace.Logon "MyProfile", , False, True
    
    Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
    
    For Each oMailItem In oFolder.Items
      With oMailItem
        
        If oMailItem.UnRead = True Then
        
        If oMailItem.Attachments.Count > 0 Then
          oMailItem.Attachments.Item(1).SaveAsFile "C:\Temp\OutlookAttachments\" & _
          oMailItem.Attachments.Item(1).Filename
       End If
      
       End If
    End With
    Next oMailItem
    Set oMailItem = Nothing
    Set oFolder = Nothing
    Set oNameSpace = Nothing
    Set oApp = Nothing
    End Sub

  6. #6

    Thread Starter
    New Member
    Join Date
    May 2000
    Posts
    4
    I am new to MAPI or this Outlook Object Library. could you please write comments on the code

    btw, oNameSpace.logon" " myprofile"
    what does it do? I don't have an Exchange SErver, do I still need to logon?
    Originally posted by Mark Sreeves
    Code:
    Sub ReadEmail()
    Dim oApp As Outlook.Application
    Dim oNameSpace As Outlook.NameSpace
    Dim oFolder As Outlook.MAPIFolder
    Dim oMailItem As Object
    Dim sMessage As String
    Set oApp = New Outlook.Application
    Set oNameSpace = oApp.GetNamespace("MAPI")
    
    oNameSpace.Logon "MyProfile", , False, True
    
    Set oFolder = oNameSpace.GetDefaultFolder(olFolderInbox)
    
    For Each oMailItem In oFolder.Items
      With oMailItem
        
        If oMailItem.UnRead = True Then
        
        If oMailItem.Attachments.Count > 0 Then
          oMailItem.Attachments.Item(1).SaveAsFile "C:\Temp\OutlookAttachments\" & _
          oMailItem.Attachments.Item(1).Filename
       End If
      
       End If
    End With
    Next oMailItem
    Set oMailItem = Nothing
    Set oFolder = Nothing
    Set oNameSpace = Nothing
    Set oApp = Nothing
    End Sub

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