Skip to Content

Archived discussions are read-only. Learn more about SAP Q&A

Problems with specifying File Extension of E-Mail attachment

Hi everybody

I have a problem that seems to be so simple that it almost drives me crazy that I cannot find a solution for it.

I need to send the content of an internal table (some lines) as a mail attachment to a specified mail address.

The format should be normal ASCII, so when I open it with any text editor (e.g. Notepad), I want to have all my lines there (including CR/LF).

The problem now is - The extension of this mail attachment must be ".key", so the attached file should have the name "L_12345.key" (for example).

For E-Mailing I use FM "SO_NEW_DOCUMENT_ATT_SEND_API1".

This part works fine, also the attachment part works in general. (I receive the mail and I receive the attachment).

BUT I get either an attachment with the name "L_12345.txt" or "L_12345.key.txt" and in correct format, or I get an attachment "L_12345.key", where the name is correct but format is wrong (no CR/LF - everything in one line).

Example:

=======

Attachment-Content should be:

Line 1

Line 2

Line 3

Name of Attachment should be: L_12345.key

What I tried:

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

    • TEST 1 **

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

......

  • Declare Attachment in Packing list. ..

ls_packing_list-transf_bin = ' '.

ls_packing_list-head_start = 1.

ls_packing_list-head_num = 0.

ls_packing_list-body_start = 7. "Startline of Attachment

ls_packing_list-body_num = 3. "No of Attachment lines

ls_packing_list-doc_type = 'RAW'.

ls_packing_list-doc_size = 3 * 255.

ls_packing_list-obj_name = 'ATT01'.

ls_packing_list-obj_descr = 'L_12345' "Attachment name

APPEND ls_packing_list TO lt_packing_list.

.....

==> Result: Attachment Filename = L_12345.txt

==> File as I need it (ASCII with CR/LF), but extension wrong

Line 1

Line 2

Line 3

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

    • TEST 2 **

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

  • Same as TEST 1, but with:

ls_packing_list-obj_descr = 'L_12345.KEY' "Attachment name

==> Result: Attachment Filename = L_12345.KEY.txt

==> File as I need it (ASCII with CR/LF), but extension wrong

Line 1

Line 2

Line 3

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

    • TEST 3 **

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

  • Declare Attachment in Packing list. ..

......

ls_packing_list-transf_bin = ' '.

ls_packing_list-head_start = 1.

ls_packing_list-head_num = 0.

ls_packing_list-body_start = 7. "Startline of Attachment

ls_packing_list-body_num = 3. "No of Attachment lines

ls_packing_list-doc_type = 'KEY'.

ls_packing_list-doc_size = 3 * 255.

ls_packing_list-obj_name = 'ATT01'.

ls_packing_list-obj_descr = 'L_12345'. "Attachment name

APPEND ls_packing_list TO lt_packing_list.

......

==> Result: Attachment Filename = L_12345.KEY

==> File Format is wrong:

Line 1 Line 2 Line3

I have tried several other Extensions (DOC_TYPE), it seems, that the File format is only correct with "RAW", but it seems with "RAW" SAP adds ".txt" as extension to the filename.

Does anyone know how I can achieve having an e-mail attachment with multiple text lines and name "<anyname>.key"

Any help (if possible with example code ?) would be highly appreciated.

Many thanks

Harald

Tags:
Not what you were looking for? View more on this topic or Ask a question