Solved

URGENT : MAPI32 API for use in VB (more points possible)

Posted on 2000-02-29
10
257 Views
Last Modified: 2008-03-17
I need to do the following with MAPI32 API (please send detailed VB code) :

1) LogOn
2) Fetch all emails from the default email client's in-box and search for all emails that have attachments (get the FileCount to know how many attachments an e-mail contains)
4) Retrieve the FileName, FilePath, Position of these attachments
5) Retrieve the name of the Sender, the Subject, NoteText, DateReceived and ConversationID of emails.
6) LogOff

This code should work with the following email clients : Outlook, Outlook Express, Exchange, Netscape.
More points may be available if the answer is very good.
Thank you.
Minette
0
Comment
Question by:minette
  • 6
  • 3
10 Comments
 
LVL 3

Expert Comment

by:carruina
ID: 2570502
Try with this code:



Private Sub Command1_Click()
MAPISession.SignOn
DoEvents
MAPIMensaje.SessionID = MAPISession.SessionID
'MAPIMensaje.FetchUnreadOnly = True
MAPIMensaje.Fetch
For i = MAPIMensaje.MsgCount - 1 To 0 Step -1
    MAPIMensaje.MsgIndex = i
    If MAPIMensaje.AttachmentCount >= 1 Then
        'Retrieve the name of the Sender, the Subject, NoteText, DateReceived and ConversationID of emails.
        MsgBox MAPIMensaje.MsgConversationID
        MsgBox MAPIMensaje.MsgOrigAddress
        MsgBox MAPIMensaje.MsgSubject
        MsgBox MAPIMensaje.MsgNoteText
        MsgBox MAPIMensaje.MsgDateReceived
        'Retrieve the FileName, FilePath, Position of these attachments
        For j = 0 To MAPIMensaje.AttachmentCount - 1
            MAPIMensaje.AttachmentIndex = j
            'In NT AttachmentName <> AttachmentPathName
            'In W95 some timmes AttachmentName = AttachmentPathName
            MsgBox MAPIMensaje.AttachmentName
            MsgBox MAPIMensaje.AttachmentPathName
            MsgBox MAPIMensaje.AttachmentPosition
        Next j
    End If
Next i
MAPISesion.SignOff
End Sub
0
 

Author Comment

by:minette
ID: 2570855
I need to achieve this only with API calls, not with the MAPI ocx.
0
 

Author Comment

by:minette
ID: 2571064
Outlook Express 5.0 and Netscape don't support MAPIMensaje.AttachmentCount

I need a solution with API calls, not the OCX.
0
Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

 
LVL 9

Expert Comment

by:Ruchi
ID: 2571564
0
 

Author Comment

by:minette
ID: 2572895
Ruchi,
Sorry but the URL you gave is for sending mail.
What I need is to read email from the in-box and have access to their attachments.
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2577101
I don't think there is to achieve this problem with API calls.

for MAPI ocx.

Go to:
http://members.home.com/abstractvb/vbcode/vbc-tut-mapi.htm
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2577122
Or, if you don't want to use MAPI, you can use socket..

go to
http://members.home.com/abstractvb/vbcode/vbc-net-smtp.htm
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2577142
0
 
LVL 9

Accepted Solution

by:
Ruchi earned 250 total points
ID: 2577158
0
 
LVL 9

Expert Comment

by:Ruchi
ID: 2603383
Minette: Where are you? Please post something so we could be of any help to you. Thank you very much.
0

Featured Post

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

825 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question