Application Development and Automation Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

Error while sending mail as (.txt) attachment.

bhupeshchandola
Explorer
0 Likes
1,179

hello,

         i am picking up the attachment from ftp server and sending mail to external address but in mail the structure of the file is not as required or i can say it is changed while sending the mail  any suggestion for the issue below are the inputs.

DATA : T_MAILHEX TYPE SOLI_TAB, 

SOLI_TAB is CHAR 255


P.S files are also attached

thanks in advance.

1 ACCEPTED SOLUTION
Read only

rosenberg_eitan
Active Contributor
0 Likes
1,085

Hi,

Try this (I am using cl_bcs )

The file is treated as binary data so we get every thing including control characters (http://en.wikipedia.org/wiki/Control_character)

Add the file as attachment.

FORM mail_1_prep_10

USING

    it_data         TYPE table

  CHANGING

    ob_document_bcs TYPE REF TO cl_document_bcs .

  CONSTANTS: c_path type string VALUE '\\<some share>\Reqformat.txt' .

  DATA: mess TYPE string .

  DATA: dataset_name TYPE string .

  dataset_name = c_path .

  OPEN DATASET dataset_name FOR INPUT IN BINARY MODE  MESSAGE mess.

  DATA: bin_data TYPE xstring  .

  READ DATASET dataset_name INTO bin_data .

  CLOSE DATASET dataset_name .

  DATA: it_solix TYPE solix_tab .

  CALL METHOD cl_bcs_convert=>xstring_to_solix

    EXPORTING

      iv_xstring = bin_data

    RECEIVING

      et_solix   = it_solix.

  DATA: attachment_subject TYPE so_obj_des .

  DATA: attachment_type TYPE so_obj_tp .

  CALL METHOD cl_bcs_utilities=>split_path

    EXPORTING

      iv_path = dataset_name

    IMPORTING

      ev_name = attachment_subject.

  CALL METHOD cl_bcs_utilities=>split_name

    EXPORTING

      iv_name      = attachment_subject

    IMPORTING

      ev_extension = attachment_type.

  TRY.

      CALL METHOD ob_document_bcs->add_attachment

        EXPORTING

          i_attachment_type    = attachment_type

          i_attachment_subject = attachment_subject

          i_att_content_hex    = it_solix.

    CATCH cx_document_bcs .

  ENDTRY.

ENDFORM .                    "mail_1_prep_10

The file retain its structure when arrived to my Outlook .

hello,

         i am picking up the attachment from ftp server and sending mail to external address but in mail the structure of the file is not as required or i can say it is changed while sending the mail  any suggestion for the issue below are the inputs.

DATA : T_MAILHEX TYPE SOLI_TAB, 

SOLI_TAB is CHAR 255


P.S files are also attached

thanks in advance.

5 REPLIES 5
Read only

Former Member
0 Likes
1,085


Hi Bhupesh,

Take the data one internal tbale with all fields as text and use below method for sending email.

 

TRY

.
cl_bcs_convert
=>string_to_solix(
EXPORTING
iv_string
= wf_string
iv_codepage
= '4103' "suitable for MS Excel, leave empty
iv_add_bom
= 'X' "for other doc types
IMPORTING
et_solix
= i_binary_content
ev_size
= wf_size ).

CATCH cx_bcs.
MESSAGE e445(so).
ENDTRY.

Regards,

Pravin

Read only

0 Likes
1,085

tried with dis one also but no luck issue is with the

T_MAILHEX TYPE SOLI_TAB, cuse it have line type CHAR 255

and my structure have char 1024 so for SOLI_TAB o/p it is wrapping the text that is why i m getting such pattern as per my conclusion what is your opinion.


P.S

thanks for reply

Read only

rosenberg_eitan
Active Contributor
0 Likes
1,086

Hi,

Try this (I am using cl_bcs )

The file is treated as binary data so we get every thing including control characters (http://en.wikipedia.org/wiki/Control_character)

Add the file as attachment.

FORM mail_1_prep_10

USING

    it_data         TYPE table

  CHANGING

    ob_document_bcs TYPE REF TO cl_document_bcs .

  CONSTANTS: c_path type string VALUE '\\<some share>\Reqformat.txt' .

  DATA: mess TYPE string .

  DATA: dataset_name TYPE string .

  dataset_name = c_path .

  OPEN DATASET dataset_name FOR INPUT IN BINARY MODE  MESSAGE mess.

  DATA: bin_data TYPE xstring  .

  READ DATASET dataset_name INTO bin_data .

  CLOSE DATASET dataset_name .

  DATA: it_solix TYPE solix_tab .

  CALL METHOD cl_bcs_convert=>xstring_to_solix

    EXPORTING

      iv_xstring = bin_data

    RECEIVING

      et_solix   = it_solix.

  DATA: attachment_subject TYPE so_obj_des .

  DATA: attachment_type TYPE so_obj_tp .

  CALL METHOD cl_bcs_utilities=>split_path

    EXPORTING

      iv_path = dataset_name

    IMPORTING

      ev_name = attachment_subject.

  CALL METHOD cl_bcs_utilities=>split_name

    EXPORTING

      iv_name      = attachment_subject

    IMPORTING

      ev_extension = attachment_type.

  TRY.

      CALL METHOD ob_document_bcs->add_attachment

        EXPORTING

          i_attachment_type    = attachment_type

          i_attachment_subject = attachment_subject

          i_att_content_hex    = it_solix.

    CATCH cx_document_bcs .

  ENDTRY.

ENDFORM .                    "mail_1_prep_10

The file retain its structure when arrived to my Outlook .

Read only

0 Likes
1,085

hi

Read only

0 Likes
1,085

Hi,

We have Microsoft windows net work and we used shared folder '\\<some share>\Reqformat.txt'

This is using UNC (http://en.wikipedia.org/wiki/Path_%28computing%29)

This works also in background job .

Assuming that when using FTP you can get the file content as binary data (bin_data) you can use the code from this point.

DATA: it_solix TYPE solix_tab .

  CALL METHOD cl_bcs_convert=>xstring_to_solix

    EXPORTING

      iv_xstring = bin_data

    RECEIVING

      et_solix   = it_solix.

     

  the rest of the code......   

 

Is the FTP server part of your local network ? 

regards.