0

Hi I am total beginner in cobol and need help in compiling this sendmail program. I need to send a mail to SMTP domain using COBOL program on OpenVMS. Can you please help me to fix this compilation error?

COBOl Program

identification division.
program-id. sendmail.
data division.
working-storage section.
01 stat pic s9(9) comp.
01 context pic 9(9) comp value 0.
01 null-item.
03 filler pic 9(4) comp value 0.
03 filler pic 9(4) comp value 0.
03 filler pic 9(9) comp value 0.
03 filler pic 9(9) comp value 0.
01 dummy-len pic 9(9) comp.
01 subject pic x(12) value 'test subject'.
01 subject-item.
03 subject-len pic 9(4) comp value 12.
03 filler pic 9(4) comp value external mail$_send_subject.
03 subject-addr pointer value reference subject.
03 filler pointer value reference dummy-len.
03 filler pic 9(9) comp value 0.
01 first_addressee pic x(64) value 'hein'.
01 second_addressee pic x(64) value 'heinvandenheuvel@xxx.yyy'.
01 addr-item.
03 addr-user-len pic 9(4) comp value 64.
03 filler pic 9(4) comp value external mail$_send_username.
03 addr-user-addr pointer value reference first_addressee.
03 filler pointer value reference dummy-len.
03 filler pic 9(9) comp value 0.
01 line1 pic x(6) value 'line 1'.
01 line2 pic x(6) value 'line 2'.
01 body-item.
03 body-file-len pic 9(4) comp value 6.
03 filler pic 9(4) comp value external mail$_send_record.
03 body-file-addr pointer value reference line1.
03 filler pointer value reference dummy-len.
03 filler pic 9(9) comp value 0.
procedure division.
main.
initialize context
call 'mail$send_begin' using context, null-item, null-item giving stat
if stat is failure
call 'lib$signal' using by value stat
else
call 'mail$send_add_attribute' using context, subject-item, null-item
giving stat
if stat is failure
call 'lib$signal' using by value stat
else
call 'mail$send_add_address' using context, addr-item, null-item
giving stat
if stat is failure
call 'lib$signal' using by value stat
end-if
set addr-user-addr to reference of second_addressee
call 'mail$send_add_address' using
context, addr-item, null-item
giving stat
if stat is failure
call 'lib$signal' using by value stat
else
call 'mail$send_add_bodypart' using
context, body-item, null-item
giving stat
if stat is failure
call 'lib$signal' using by value stat
else
set body-file-addr to reference of line2
call 'mail$send_add_bodypart' using
context, body-item, null-item
giving stat
if stat is failure
call 'lib$signal' using by value stat
else
call 'mail$send_message' using
context, null-item, null-item
giving stat
if stat is failure
call 'lib$signal' using by value stat
end-if
end-if
end-if
end-if
end-if
if stat is failure
call 'mail$send_abort' using context, null-item, null-item
giving stat
if stat is failure
call 'lib$signal' using by value stat
end-if
else
call 'mail$send_end' using context, null-item, null-item
giving stat
if stat is failure
call 'lib$signal' using by value stat
end-if
end-if
exit program.

Error during compilation

I%ILINK-W-NUDFSYMS, 3 undefined symbols:
%ILINK-I-UDFSYM,        MAIL$_SEND_RECORD
%ILINK-I-UDFSYM,        MAIL$_SEND_SUBJECT
%ILINK-I-UDFSYM,        MAIL$_SEND_USERNAME
%ILINK-W-USEUNDEF, undefined symbol MAIL$_SEND_SUBJECT referenced
        section: $LOCAL$
        offset: %X000000000000003A
        module: SENDMAIL
        file: $DISK54:[DEVL.OHN.UH15]TENDMAIL.OBJ;3
%ILINK-W-USEUNDEF, undefined symbol MAIL$_SEND_USERNAME referenced
        section: $LOCAL$
        offset: %X00000000000000CA
        module: SENDMAIL
        file: $DISK54:[DEVL.OHN.UH15]TENDMAIL.OBJ;3
%ILINK-W-USEUNDEF, undefined symbol MAIL$_SEND_RECORD referenced
        section: $LOCAL$
        offset: %X00000000000000EA
        module: SENDMAIL
        file: $DISK54:[DEVL.OHN.UH15]TENDMAIL.OBJ;3
%ILINK-W-USEUNDEF, undefined symbol MAIL$_SEND_SUBJECT referenced
        section: $LOCAL$
        offset: %X0000000000000258
        module: SENDMAIL
        file: $DISK54:[DEVL.OHN.UH15]TENDMAIL.OBJ;3
%ILINK-W-USEUNDEF, undefined symbol MAIL$_SEND_USERNAME referenced
        section: $LOCAL$
        offset: %X0000000000000330
        module: SENDMAIL
        file: $DISK54:[DEVL.OHN.UH15]TENDMAIL.OBJ;3
%ILINK-W-USEUNDEF, undefined symbol MAIL$_SEND_RECORD referenced
        section: $LOCAL$
        offset: %X00000000000003D8
        module: SENDMAIL
        file: $DISK54:[DEVL.OHN.UH15]TENDMAIL.OBJ;3
$               set noverify
jackJoe
  • 11,078
  • 8
  • 49
  • 64
  • You are giving EXTERNAL values, and these have not been resolved. Look closer at places where this program exists on the web, and read around them. – Bill Woodger Mar 28 '14 at 09:20
  • You are missing a link library for the Mail system. Check out [this link](http://h71000.www7.hp.com/doc/82final/5841/5841pro_074.html) for general information concerning resolving external symobols at link time. Unfortunately I was not able to find anything relating to which library you need to get the MAIL$... symbols defined. – NealB Mar 28 '14 at 15:51
  • What version of VMS are you using? It looks like you might have found [documentation](http://h71000.www7.hp.com/doc/84final/4493/4493pro_045.html#mail_intro) for a library that might not exist on your system. Can you provide the LINK command and any options files you are using? – HABO Mar 28 '14 at 17:23
  • 1
    Honestly? No shame! READ before WRITING! http://h30499.www3.hp.com/t5/Languages-and-Scripting/Cobol-calling-MAIL-routines-to-send-SMTP/td-p/4176927#.UzYwKPldXcw and 5 years later I still think that calling LIB$SPAWN is the better way to go 9 out of 10 times. – Hein Mar 29 '14 at 02:32

1 Answers1

2

The Cobol program above requests the value for (mail) symbols to be provided externally by the linker.

You'd have to provide it the MAIL$ symbols for example by creating a helper module MAILDEF For example:

$ cre maildef.mar
.TITLE MAILDEF
$MAILDEF GLOBAL
$MAILMSGDEF GLOBAL
.END
Exit
$ macr maildef
$ cob mail
$ link mail,maildef

Good luck, Hein

Hein
  • 1,453
  • 8
  • 8