Read the content of email and text attachment


if i receive job-order/sales-order in an email, ...
(a) how can i use visual basic 6.0 to assign the contents to a eg...memo.textRTF,
(b) and also to handle an attachment (eg. job.csv) , say save it to a temp folder. ( i guess the next thing is just to open the job.csv and read the contents.)

Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Start new project
Add the microsoft mapi controls
name MapiSessions1 to: mapsess
name MapiMessages1 to : mapmess

'ADD 2 command buttons
'ADD 1 Textbox ..If you must change textbox 1 to a richtextbox

'Copy and Paste code into form

Option Explicit
Dim strMessageCount As String
Dim strPrintMessage As String
Dim bNewSession
Private Function LogOn() As Boolean

    If mapSess.NewSession Then
        MsgBox "Session already established"
        Exit Function
    End If
    On Error GoTo errLogInFail
    With mapSess
        .DownLoadMail = False
        .LogonUI = True
        LogOn = True
        .NewSession = True
        bNewSession = .NewSession
        mapMess.SessionID = .SessionID
    End With
    Exit Function
    Debug.Print Err.Number, Err.Description
    If Err.Number = 32003 Then
        MsgBox "Canceled Login"
        LogOn = False
    End If
    Exit Function
End Function
Private Sub Fetch()

    With mapMess
        .FetchUnreadOnly = False
        strMessageCount = LTrim(Str(.MsgIndex + 1)) & " of " & LTrim(Str(.MsgCount))
    strPrintMessage = .MsgNoteText
    Debug.Print strMessageCount
    Text1.Text = strPrintMessage
    End With
End Sub

Private Sub Command2_Click()
With mapMess
If .MsgIndex < .MsgCount - 1 Then
        .MsgIndex = .MsgIndex + 1
        Debug.Print strMessageCount
        strPrintMessage = .MsgNoteText
        Text1.Text = strPrintMessage
        Debug.Print "End of e-mail messages"
    End If
    End With
End Sub

Private Sub Form_Load()
Command1.Caption = "read mail"
Command2.Caption = "read next mail"
End Sub

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
FiacreAuthor Commented:
does your above codes help to read any attachment that is CSV or TXT extension ?

For another question, i have posted in a new thread, related to this. (Qn: How to transfer email read/opened to another folder ?)
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic Classic

From novice to tech pro — start learning today.