?
Solved

MAPI Attachment Access

Posted on 1998-04-20
2
Medium Priority
?
734 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
[X]
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
2 Comments
 
LVL 5

Accepted Solution

by:
bin_huwairib earned 400 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

Want to be a Web Developer? Get Certified Today!

Enroll in the Certified Web Development Professional course package to learn HTML, Javascript, and PHP. Build a solid foundation to work toward your dream job!

Question has a verified solution.

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

Most everyone who has done any programming in VB6 knows that you can do something in code like Debug.Print MyVar and that when the program runs from the IDE, the value of MyVar will be displayed in the Immediate Window. Less well known is Debug.Asse…
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
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…
Suggested Courses
Course of the Month9 days, 17 hours left to enroll

762 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