Solved

MAPI Attachment Access

Posted on 1998-04-20
2
724 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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

759 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

Need Help in Real-Time?

Connect with top rated Experts

19 Experts available now in Live!

Get 1:1 Help Now