cancel
Showing results for 
Search instead for 
Did you mean: 

Sending Sapscript as mail with multiple attachments

frank_stdle
Participant
0 Kudos

Hi

I have a requirement to send a shipping document as a mail with multiple PDF attachments. Currently we have defined an output type of "External send" which automatically sends the shipping document as a mail, but we also need to attach additional PDF documents to the mail.

We use our own Z-program to create the shipping document. Should I redefine the output type to "Print" and convert and send the document and attachments from inside the print program, or is there a better way?

thanks!

Frank

Accepted Solutions (1)

Accepted Solutions (1)

frank_stdle
Participant

I have now created functionality to send the sapscript document as a mail with attachments from the printing program. The mail is sent immediately after "CLOSE_FORM". I am using transmission medium type "External send". The problem now is that I get two mails -- one sent by my code and one sent from SAP's code. How can I prevent the SAP code from also sending the document?

Sandra_Rossi
Active Contributor
0 Kudos

I guess you both called OPEN_FORM with MAIL_RECIPIENT parameter filled, and have sent the mail using CL_BCS class?

If so, remove parameters MAIL_*

frank_stdle
Participant
0 Kudos

Hi Sandra, thank you for replying --

I removed the MAIL* parameteres from OPEN_FORM, but that causes OPEN_FORM to return SY-SUBRC = 6, and processing is terminated.

Sandra_Rossi
Active Contributor
0 Kudos

> sy-subrc = 6

I don't know your program, so I can only guess it corresponds to MAIL_OPTIONS exception?

If so, you probably used parameter DEVICE = 'MAIL'. Instead, use 'PRINTER' for example. You may use TDGETOTF field of the OPTIONS parameter to get the OTF data instead of generating a spool.

frank_stdle
Participant
0 Kudos

I don't know your program, so I can only guess it corresponds to MAIL_OPTIONS exception?

Sorry, you guessed correct, it's the MAIL_OPTIONS exception

I am using the TDFGETOTF already to get hold of the OTF and convert to PDF.

I changed device from MAIL to OTF_MEM (seems like the logical option here?) and now it works just fine.

Thanks!

Sandra_Rossi
Active Contributor
0 Kudos

> I changed device from MAIL to OTF_MEM

Excerpt from [Note 413478 - Only COURIER font for PDF conversion|http://service.sap.com/sap/support/notes/413478]: "DEVICE OTF_MEM is obsolete and should no longer be used". Solution indicated in RSTXPDFT is to use device PRINTER.

frank_stdle
Participant
0 Kudos

Ok, I changed device to "PRINTER", works well (and nothing is sent to spool).

Answers (1)

Answers (1)

Former Member
0 Kudos

Hi,

first you have to explain how these PDF documents are generated or whether these already exist somewhere. There are some function modules which are used for sending emails with attachments, like SO_NEW_DOCUMENT_ATT_SEND_API1. In the parameter "contents_bin" you transfer the files as attachment.

frank_stdle
Participant
0 Kudos

Hi Jorge,

these additional documents to be attached already exist as attachments to the deliveries under the shipment. They have been attached using "Create attachment" from the object services menu.

Sandra_Rossi
Active Contributor
0 Kudos

I don't recommend the use of SO* function modules as they are obsolete (according to SAP notes) and error prone.

Instead, use the more robust CL_BCS class : [wiki Sending Mails - Home Page|http://wiki.sdn.sap.com/wiki/display/ABAP/SendingMails-HomePage].

As you'll see there, you can combine (for example) these 2 snippets:

  • [Sending mail with attachment using Object Oriented Approach|http://wiki.sdn.sap.com/wiki/display/Snippets/SendingmailwithattachmentusingObjectOriented+Approach] (for sending a mail)

  • and [Converting Spool to PDF and sending via mail to external email id|http://wiki.sdn.sap.com/wiki/display/Snippets/ABAP-SendingGOSattachmentstoanemailaddress] (the part to read GOS)

frank_stdle
Participant
0 Kudos

Thanks to both of you for your input, but my question is really mainly whether it is possible through configuration (transaction NACE) and possibly user exits to attach additional documents to the mail that is generated when the shipment is outputted. If this is not possible, I will use the methods you propose and create a mail with attachments myself in the print program.

thanks,

Frank