Link to home
Start Free TrialLog in
Avatar of SaadDani
SaadDaniFlag for Israel

asked on

MAPI controls

Is it possible to send an attached file using MAPI Message control?
If yes, how?
Avatar of Jim Dettman (EE MVE)
Jim Dettman (EE MVE)
Flag of United States of America image

No, it's not possible to use the MAPI control from VB.

  There are many other alternatives, simplest of which is the sendobject command.  You can also purchase a control that works with Access or write your own interface.  

  I could give you a lot more info if I knew what version of Access this was for.

Jim.
Avatar of simonbennett
simonbennett

Yup - its possible. You just need devel access to MSMAPI32.OCX - you will get this if you install VB5 or 6. Simply Insert, ActiveXControl and select MSMAPI32.OCX.

Search the access area for "MAPI" and you can find the reams of code I have posted in the past.....

HTH

Simon
From the web:

"MAPI makes adding attachments to your email messages very simple. You don't need to encode your binary file using MIME or UUENCODE, instead the MAPIMessages control will handle all the encoding for you. (If you've ever seen the MIME specification, you will be VERY grateful for this feature.)"

NOTE:Please change the RecipAddress. I don't want to get a million Autoexec.bat files!

Private Sub Form_Load()
    MAPISession1.SignOn
   
    MAPIMessages1.SessionID = MAPISession1.SessionID
   
    MAPIMessages1.Compose
    MAPIMessages1.RecipAddress = "abstractvb@home.com"
    MAPIMessages1.MsgSubject = "Here is my Autoexec"
    MAPIMessages1.MsgNoteText = "Below you will find the file."
       
    'Add the Attachment at the end of the message
    MAPIMessages1.AttachmentPosition = Len(MAPIMessages1.MsgNoteText)
   
    'Set the type to a data file
    MAPIMessages1.AttachmentType = mapData
   
    'Give it a name
    MAPIMessages1.AttachmentName = "Autoexec File"
   
    'Specify what file to send
    MAPIMessages1.AttachmentPathName = "c:\autoexec.bat"
   
    MAPIMessages1.Send True
   
    MAPISession1.SignOff
End Sub

Or, you can go to
http://support.microsoft.com/support/kb/articles/Q186/1/48.ASP
Avatar of SaadDani

ASKER

There is a problem with the line
MAPIMessages1.Send True
     
what to do?
What error message do you get?
Hello
the error message is

RunTime Error '32002'
Unspecified Failure has occured

bye
Are you running on Windows NT?
ASKER CERTIFIED SOLUTION
Avatar of Ruchi
Ruchi

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Did you read this link I gave???

"PRB: Error 32002 Working with
   Attachments in MAPI Controls"
http://support.microsoft.com/support/kb/articles/Q186/1/48.ASP

Take a look at:
http://support.microsoft.com/support/kb/articles/Q173/8/53.ASP