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
eric07Asked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Erick37Commented:
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?
0
eric07Author Commented:
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
0
eric07Author Commented:
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
0
The Ultimate Tool Kit for Technolgy Solution Provi

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy for valuable how-to assets including sample agreements, checklists, flowcharts, and more!

Erick37Commented:
"PRB: Error 32002 "Unspecified Error" When Adding an Attachment"

http://support.microsoft.com/support/kb/articles/Q173/8/53.ASP
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Erick37Commented:
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.
0
eric07Author Commented:
Thank you,
it solved my problem.

yeah
0
Erick37Commented:
Great! :-)
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Development

From novice to tech pro — start learning today.