Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6882731
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T05:17:30+00:00 2026-05-27T05:17:30+00:00

Has anyone been able to download email that contains attachment with CDO in vb6?

  • 0

Has anyone been able to download email that contains attachment with CDO in vb6?

Can you help me with an example?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T05:17:31+00:00Added an answer on May 27, 2026 at 5:17 am

    I’m still not sure where you want to retrieve email from but here is some code for retrieving email from an Exchange server. I did this as an experiment to learn some methods I would need on another project so it is not production quality but should get you started. This code is dependent on an Exchange client already being setup on the computer this is running on.

    This function creates a session and logs in:

    Function Util_CreateSessionAndLogon(Optional LogOnName As Variant) As Boolean
    
        On Error GoTo err_CreateSessionAndLogon
    
        Set objSession = CreateObject("MAPI.Session")
        objSession.Logon , , False, False
        Util_CreateSessionAndLogon = True
        Exit Function
    
    err_CreateSessionAndLogon:
        Util_CreateSessionAndLogon = False
    
        Exit Function
    
    End Function
    

    This function get information on items in the inbox and demonstrates some of the available properties.

    Public Function GetMessageInfo(ByRef msgArray() As String) As Long
        Dim objInboxFolder As Folder  ' Folder object
        Dim objInMessages As mapi.Messages ' Messages collection
        Dim objMessage As Message     ' Message object
        Dim InfoRtnString
        Dim i As Long
        Dim lngMsgCount As Long
    
        InfoRtnString = ""
    
        If objSession Is Nothing Then
            If Util_CreateSessionAndLogon = False Then
                Err.Raise 429, "IBS_MAPI_CLASS", "Unable to create MAPI session object."
                Exit Function
            End If
        End If
    
        Set objInboxFolder = objSession.Inbox
        Set objInMessages = objInboxFolder.Messages
    
        lngMsgCount = objInMessages.Count
        ReDim msgArray(0)   'initalize the array
    
        For Each objMessage In objInMessages
            If i / lngMsgCount * 100 > 100 Then
                RaiseEvent PercentDone(100)
            Else
                RaiseEvent PercentDone(i / lngMsgCount * 100)
            End If
    
            InfoRtnString = ""
            i = i + 1
            ReDim Preserve msgArray(i)
            InfoRtnString = InfoRtnString & Chr$(0) & objMessage.ID
            InfoRtnString = InfoRtnString & Chr$(0) & objMessage.Subject
            InfoRtnString = InfoRtnString & Chr$(0) & objMessage.Sender
            InfoRtnString = InfoRtnString & Chr$(0) & objMessage.TimeSent
            InfoRtnString = InfoRtnString & Chr$(0) & objMessage.TimeReceived
            InfoRtnString = InfoRtnString & Chr$(0) & "" 'objMessage.Text
            InfoRtnString = InfoRtnString & Chr$(0) & objMessage.Unread
            InfoRtnString = InfoRtnString & Chr$(0) & objMessage.Attachments.Count
            msgArray(i) = InfoRtnString
            DoEvents
        Next
    
        GetMessageInfo = i
    
    End Function
    

    This function demonstrates getting attachments from a message.

    Function GetAttachments(msgID As String, lstBox As ListBox) As Boolean
        Dim objMessage As Message ' Messages object
        Dim AttchName As String
        Dim i As Integer
        Dim x As Long
    
        If objSession Is Nothing Then
            x = Util_CreateSessionAndLogon()
        End If
    
        Set objMessage = objSession.GetMessage(msgID)
    
        For i = 1 To objMessage.Attachments.Count
            Select Case objMessage.Attachments.Item(i).Type
    
                Case Is = 1 'contents of a file
                    AttchName = objMessage.Attachments.Item(i).Name
                    If Trim$(AttchName) = "" Then
                        lstBox.AddItem "Could not read"
                    Else
                        lstBox.AddItem AttchName
                    End If
    
                    lstBox.ItemData(lstBox.NewIndex) = i
    
                Case Is = 2 'link to a file
                    lstBox.AddItem objMessage.Attachments.Item(i).Name
                    lstBox.ItemData(lstBox.NewIndex) = i
    
                Case Is = 1 'OLE object
    
    
                Case Is = 4 'embedded object
                    lstBox.AddItem "Embedded Object"
                    lstBox.ItemData(lstBox.NewIndex) = i
    
            End Select
    
        Next i
    
        GetAttachments = True
    
    End Function
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

has anyone been able to download the spring framework 3.0.0.M4 release from the spring
Has anyone been able to do this? Coming from Objective-C, I know that you
Has anyone been able to customize jQGrid? While I'd like something easy I can
Has anyone been able to successfully unit test methods that are, by necessity, coupled
Has anyone been able to implement a scrollable table in HTML where the TOP
Has anyone been able to get Windows Installer to use the InstallUISequence table during
I'm wondering whether anyone has been able to use the Microsoft Chart control in
Now that Google Earth has been released for Android 2.1, does anyone know what,
Has anyone been able to install ffmpeg-php on osx? i was able to install
Has anyone been able to get the Areas in ASP.NET MVC 2 to work?

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.