如何从我的COBOL程序通过smtp发送电子邮件

时间:2014-03-28 08:41:32

标签: cobol openvms

您好我是cobol的初学者,需要帮助编译这个sendmail程序。 我需要使用OpenVMS上的COBOL程序向SMTP域发送邮件。 你能帮我修一下这个编译错误吗?

COBOl计划

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.

编译期间出错

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

1 个答案:

答案 0 :(得分:2)

上面的Cobol程序请求链接器在外部提供(邮件)符号的值。

您必须为其提供MAIL $符号,例如通过创建辅助模块MAILDEF 例如:

$ cre maildef.mar
.TITLE MAILDEF
$MAILDEF GLOBAL
$MAILMSGDEF GLOBAL
.END
Exit
$ macr maildef
$ cob mail
$ link mail,maildef
祝你好运, 海因