Skip to Content
0
Former Member
Sep 08, 2009 at 10:24 AM

Send Mail with Attachment to Outlook - Version 3.1i

31 Views

Hi Every one,

I need to draft a logic in 3.1i system that sends a mail to Microsoft outlook inbox with attachments.

The below flow of logic is the core part of the code that I am using for mails without attachments.

OPEN DATASET P_FNAME FOR OUTPUT IN TEXT MODE.

IF P_FROM NE SPACE.

CONCATENATE 'From:'(MFR) P_FROM INTO P_FROM SEPARATED BY SPACE.

TRANSFER P_FROM TO P_FNAME.

ENDIF.

IF P_TO NE SPACE.

CONCATENATE 'To:'(MTO) P_TO INTO P_TO SEPARATED BY SPACE.

TRANSFER P_TO TO P_FNAME.

ENDIF.

IF P_CC NE SPACE.

CONCATENATE 'Cc:'(MCC) P_CC INTO P_CC SEPARATED BY SPACE.

TRANSFER P_CC TO P_FNAME.

ENDIF.

IF P_BCC NE SPACE.

CONCATENATE 'Bcc:'(MBC) P_BCC INTO P_BCC SEPARATED BY SPACE.

TRANSFER P_BCC TO P_FNAME.

ENDIF.

IF P_SUB NE SPACE.

CONCATENATE 'Subject:'(MSB) P_SUB INTO P_SUB SEPARATED BY SPACE.

TRANSFER P_SUB TO P_FNAME.

ENDIF.

LOOP AT S_BODY.

TRANSFER S_BODY-LOW TO P_FNAME.

ENDLOOP.

CLOSE DATASET P_FNAME.

************************************************************************

  • Run External Command: SENDMAIL

CLEAR PARCOM.

REFRESH OUT_LINES.

concatenate 'sendmail -t < ' p_fname into parcom.

  • Execute Command

call 'system' id 'COMMAND' field PARCOM id 'TAB' field out_lines-SYS .

I have tried creating another file in AL11 and using it as attachment after the transfer of subject text in the above code, like -

CONCATENATE 'Attach:'(MAT) '/usr/sap/GS1/DVEBMGS20/work/attach.txt INTO P_ATTACH SEPARATED BY SPACE.

TRANSFER P_ATTACH TO P_FNAME.

But, this did not work.

Need your help in extending the code to send attachments.

Thanks in Advance,

Regards

Govardhan

Edited by: Gova12 on Sep 8, 2009 12:25 PM

Edited by: Gova12 on Sep 8, 2009 12:57 PM