Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

MAPI Attachment Access

Posted on 1998-04-20
2
730 Views
Last Modified: 2010-05-18
I am trying to access information on a file attachment in Exchange using MAPI in VB 5.0.  This is explained quite well in the MS Knowledgebase but the code examples I find there do not work for me.  All the other MAPI examples seem to work fine when when I try to check any Attachment property I get a "run time error 438 - Object doesn't support this property or method" error.

I have tried it both using the MAPI on form controls and the  Set objSession = CreateObject("mapi.session") commands.

My code is:
  MapiSess.Action = 1
  If Err <> 0 Then
      MsgBox "Logon Failure: " + Error$
  Else
      MapiMess.SessionID = MapiSess.SessionID
  End If
  On Error GoTo 0
  MsgBox MapiMess(1).AttachmentCount 'This failes
  MapiMess(1).AttachmentIndex = 1 'This fails
  MsgBox MapiMess(1).AttachmentPathName 'This fails

I have also tried fetching the message first with no improvement.  My guess is that I'm not including some necessary reference or component but I can't figure out which.

I am referencing:
Microsoft MAPI Controls 5.0 (sp2)
Microsoft Active Messaging 1.1 object library

My conponents are:
Microsoft MAPI Controls 5.0 (sp2)

Any help is greatly appreciated.

Ken
0
Comment
Question by:kfenske
2 Comments
 
LVL 5

Accepted Solution

by:
bin_huwairib earned 100 total points
ID: 1425983
kfenske,
To access a file attachment using MAPI control, you must create a message set for all messages in the inbox (after establishing MAPI Session) by using Fetch method, and then you can access each message in that set with MsgIndex property and finally you can use AttachmentIndex property to access selected message attachment.

Example:
MapiSess.Action = 1
If Err <> 0 Then
 MsgBox "Logon Failure: " + Error$
Else
 MapiMess.SessionID = MapiSess.SessionID
 MapiMess.FetchUnreadOnly = False
 MapiMess.Fetch
 For I = 0 To MapiMess.MsgCount - 1
  MapiMess.MsgIndex = I
  MsgBox "From : " + MapiMess.MsgOrigDisplayName + vbCrLf + _
   "Attachment Count : " + Trim(MapiMess.AttachmentCount) + vbCrLf + _
   "Attachment Path : " + Trim(MapiMess.AttachmentPathName)
 Next
End If



0
 

Author Comment

by:kfenske
ID: 1425984
Excellent answer, this cleared it all up.

Ken
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
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…
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…

860 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