[Migrated content. Thread originally posted on 20 May 2003]
There is an example program on the Acucorp web site called
MSEmail which is a great way to call outlook to send email,
Unfortunately the example cannot add an attachment, Does anyone have any experience adding an attachment,
I can do it in VB
eg:
Mailitem.Attachment.Add "c:\\test\\test.txt"
I have tried all possible ways to do this with the MODIFY
in cobol but nothing seems to work
Any Ideas Please
This should do the trick.
WORKING-STORAGE SECTION.
77 MySession HANDLE OF MapiSession OF MSMAPI.
77 MyMessage HANDLE OF MAPIMESSAGES OF MSMAPI.
77 MYSESSID PIC S9(9) COMP-5.
PROCEDURE DIVISION.
MAIN-LOGIC.
CREATE MapiSession OF MSMAPI
LICENSE-KEY "mgkgtgnnmnmninigthkgogggvmkhinjggnvm"
HANDLE IN MySession.
CREATE MAPIMESSAGES OF MSMAPI
LICENSE-KEY "mgkgtgnnmnmninigthkgogggvmkhinjggnvm"
HANDLE IN MyMessage.
MODIFY MySession Action = 1. | SESSION_SIGNON
INQUIRE MySession SessionID IN MySessID.
MODIFY MyMessage SessionID = MySessID.
MODIFY MyMessage Action = 6. | MESSAGE_COMPOSE
MODIFY MyMessage MsgSubject = "This is the subject".
MODIFY MyMessage MsgNoteText =
"Hello world from ACUCOBOL-GT using OLE MAPI".
MODIFY MyMessage AttachmentIndex = 0
AttachmentType = 0 | ATTACHTYPE_DATA
AttachmentName = "This COBOL code"
AttachmentPosition = 0
AttachmentPathName =
"olemapi.cbl".
MODIFY MyMessage RecipIndex = 0.
MODIFY MyMessage RecipDisplayName =
"cheesle@online.no".
MODIFY MyMessage RecipType = 1.
MODIFY MyMessage Action = 13. | MESSAGE_RESOLVENAME
MODIFY MyMessage Action = 3. | MESSAGE_SEND
MODIFY MySession Action = 2. | SESSION_SIGNOFF
DISPLAY LABEL "Email transmit done..." AT 1501.
ACCEPT OMITTED AT 1523.
DESTROY MyMessage.
DESTROY MySession.
MAIN-LOGIC-END.
STOP RUN.