Link to home
Start Free TrialLog in
Avatar of eric07
eric07

asked on

Using MAPI Active X Control and attachments.

Hi I'm trying to add an attachment to an email application.
I can create the email and send it but I keep getting an error every time I try and attach text file like so:

I've logged on the MAPI server already

MAPIMess.Action = 6
       

MAPIMess.RecipIndex = 0
MAPIMess.RecipDisplayName = "eric07@earthlink.net"
MAPIMess.MsgSubject = "This is a test"

MAPIMess.Action = 3

will send the email and I receive it ok

but know to add the code to add the
autoexec.bat as an attachment I get errors.

MapiMess.AttachmentIndex = MapiMess.AttachmentCount
MapiMess.AttachmentName = "autoexec.bat"        
MapiMess.AttachmentPathName = "c:\autoexec.bat"
MapiMess.AttachmentPosition = MapiMess.AttachmentIndex
MapiMess.AttachmentType = 0

MAPIMess.Action = 3

can anyone help figure this out.
Thanks
Avatar of Erick37
Erick37
Flag of United States of America image

I believe if you have an .AttachmentPosition value, you must assign text in the .msgNoteText property.  And the value of .AttachmentPosition must be <= Len(.msgNoteText)

P.S what is the error you are getting?
Avatar of eric07
eric07

ASKER

Runtime error: '32002'

Unspecified failure has occured

 MAPIMess.MsgSubject = "This is a test"
           MAPIMess.AttachmentIndex = MAPIMess.AttachmentCount
            MAPIMess.AttachmentIndex = MAPIMess.AttachmentIndex
           MAPIMess.AttachmentName = "autoexec.bat"
            MAPIMess.AttachmentPathName = "c:\autoexec.bat"
            MAPIMess.MsgNoteText = "Note Text"
            MAPIMess.AttachmentPosition = Len(MAPIMess.MsgNoteText)
            MAPIMess.AttachmentType = 0

Thanks
Avatar of eric07

ASKER

Runtime error: '32002'

Unspecified failure has occured

 MAPIMess.MsgSubject = "This is a test"
           MAPIMess.AttachmentIndex = MAPIMess.AttachmentCount
            MAPIMess.AttachmentIndex = MAPIMess.AttachmentIndex
           MAPIMess.AttachmentName = "autoexec.bat"
            MAPIMess.AttachmentPathName = "c:\autoexec.bat"
            MAPIMess.MsgNoteText = "Note Text"
            MAPIMess.AttachmentPosition = Len(MAPIMess.MsgNoteText)
            MAPIMess.AttachmentType = 0

Thanks
ASKER CERTIFIED SOLUTION
Avatar of Erick37
Erick37
Flag of United States of America image

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
Here's another KB dealing with setting the .AttachmentPosition

http://support.microsoft.com/support/kb/articles/Q186/1/48.ASP

Also, if you only have one attachment, set the .AttachmentIndex = 0.
Avatar of eric07

ASKER

Thank you,
it solved my problem.

yeah
Great! :-)