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

Problem with Email attachment

Former Member
0 Likes
2,497

Hi,

I am using the method add_attachment, to add attachments to my Email.

The mail is being triggered successfully with the attachments, but with the following problems:

a. The attachment is being populated with incomplete data.

CALL METHOD document->add_attachment
 EXPORTING
 i_attachment_type    = file_type
 i_attachment_subject = attach_name1
 i_att_content_text   = it_attach[].
 

Although it_attach[] has all the data in it, the data in the attachment is incomplete.

Is there a limit on the attachment size? How can this be increased.

b. There is a space after every character in the attachment data. How can this be corrected?

Thanks,

Smitha.

1 ACCEPTED SOLUTION
Read only

former_member378318
Contributor
0 Likes
2,107

Hi Smitha,

Can you please give more information on the type of data in it_attach[] and how you are populating this internal table. Does the table contain an ABAP List, simple text or other data?

17 REPLIES 17
Read only

Former Member
0 Likes
2,107

Hi,

Here are some links which will have the example Programs

Regards

Sudheer

Read only

former_member194669
Active Contributor
0 Likes
2,107

Please check my thread

aRs

Read only

0 Likes
2,107

Sudheer,aRs,

Thanks for the replies.

Will check the SCOT transaction and revert.

Regards,

Smitha.

Message was edited by:

Smitha Rao

Read only

0 Likes
2,107

Hi,

The configurations mentioned in the links above, have already been made in the SCOT transaction.

I am still facing the same issues.

Any ideas?

Thanks,

Smitha.

Read only

Former Member
0 Likes
2,107

Hi,

Check the following link:

http://www.sap-img.com/abap/sending-email-with-attachment.htm

Regards,

Bhaskar

Read only

athavanraja
Active Contributor
0 Likes
2,107

can you try converting the it_attach to binary and then pass it to i_att_content_hex to see whether you still have that problem?

Read only

0 Likes
2,107

Hi Durairaj,

I am new to ABAP. Could you please let me know how this can be done?

How do I convert text to binary before assigning it to i_att_content_hex?

Thanks,

Smitha.

Read only

former_member378318
Contributor
0 Likes
2,108

Hi Smitha,

Can you please give more information on the type of data in it_attach[] and how you are populating this internal table. Does the table contain an ABAP List, simple text or other data?

Read only

0 Likes
2,107

Hi Surbjeet,

The data in the it_attach[] is simple text.

This table is one of the import parameters.

Thanks,

Smitha.

Read only

0 Likes
2,107

data: text type bcsy_text.

data: xtext type standard table of solix .

call function 'SO_SOLITAB_TO_SOLIXTAB'

exporting

ip_solitab = text

importing

ep_solixtab = xtext .

call method document->add_attachment

exporting

i_attachment_type = 'htm'

i_attachment_subject = atta_sub

i_att_content_hex = xtext.

Raja

Read only

0 Likes
2,107

Is i_attachment_type set to 'RAW'?

Read only

0 Likes
2,107

Thanks Raja,

I get the complete content in the attachments now.

But the data in the attachment is not formatted correctly.

For example, "valid data" in the attachment looks like "v a l i d d a t a".

Any clues on this?

Thanks,

Smitha.

Read only

0 Likes
2,107

can you post your complete code, we can then check whats going wrong

Read only

0 Likes
2,107

Below is the code:


FUNCTION Z_XI_SEND_MAIL_ATT_DYN_EMAILID.
*"----------------------------------------------------------------------
*"*"Local Interface:
*"  IMPORTING
*"     VALUE(SUBJECT) TYPE  SO_OBJ_DES OPTIONAL
*"     VALUE(ATTACH_NAME1) TYPE  SOOD-OBJDES OPTIONAL
*"     VALUE(FILE_TYPE) TYPE  SOODK-OBJTP OPTIONAL
*"     VALUE(ATTACH_NAME2) TYPE  SOOD-OBJDES OPTIONAL
*"  TABLES
*"      IT_CONTENT TYPE  SOLI_TAB OPTIONAL
*"      IT_ATTACH TYPE  SOLI_TAB OPTIONAL
*"      IT_ATTACH1 TYPE  SOLI_TAB OPTIONAL
*"      IT_EMAILID TYPE  SOLI_TAB OPTIONAL
*"----------------------------------------------------------------------

 DATA: send_request       TYPE REF TO cl_bcs.
  DATA: document           TYPE REF TO cl_document_bcs.
  DATA: sender             TYPE REF TO cl_sapuser_bcs.
  DATA: recipient          TYPE REF TO if_recipient_bcs.
  DATA: exception_info     TYPE REF TO if_os_exception_info,
  bcs_exception      TYPE REF TO cx_document_bcs.
  DATA i_attachment_size TYPE sood-objlen.
  DATA it_recv LIKE zmailmap OCCURS 0 WITH HEADER LINE.
  DATA ext(3).
  DATA: it_attach_hex type standard table of solix .
  DATA: it_attach1_hex type standard table of solix .



* Create persistent send request
  send_request = cl_bcs=>create_persistent( ).

  TRY.

      document = cl_document_bcs=>create_document(
                                    i_type    = 'txt'
                                    i_text = it_content[]
                                    i_subject = subject ).

      DESCRIBE TABLE it_attach.

      SPLIT attach_name1 AT '.' INTO attach_name1 ext.

**************** Convert text to binary***********************

call function 'SO_SOLITAB_TO_SOLIXTAB'
exporting
ip_solitab = it_attach[]
importing
ep_solixtab = it_attach_hex[].

      CALL METHOD document->add_attachment
        EXPORTING
          i_attachment_type    = file_type
          i_attachment_subject = attach_name1
          i_att_content_hex   = it_attach_hex[].





****Additional code for QRN Interface*****
      IF file_type = 'QRN'.
        SPLIT attach_name2 AT '.' INTO attach_name2 ext.
        DESCRIBE TABLE it_attach1.


*********Convert text to binary***************


call function 'SO_SOLITAB_TO_SOLIXTAB'
exporting
ip_solitab = it_attach1[]
importing
ep_solixtab = it_attach1_hex[].



        CALL METHOD document->add_attachment
          EXPORTING
            i_attachment_type    = 'QTX'
            i_attachment_subject = attach_name2
            i_att_content_hex   = it_attach1_hex[].
      ENDIF.
*********************************************

* Add document to send request
      CALL METHOD send_request->set_document( document ).
* Get sender object
      sender = cl_sapuser_bcs=>create( sy-uname ).

* Add sender
      CALL METHOD send_request->set_sender
        EXPORTING
        i_sender = sender.


********Determine the receipients (Extra code added for QRN interface - 31st May 2007)************

****Add Reciepents

IF file_type = 'QRN'.

  LOOP AT IT_EMAILID.
  it_recv-MAILID = IT_EMAILID.
  APPEND it_recv.
  CLEAR it_recv.
  ENDLOOP.

**it_recv-mailid = IT_EMAILID.
**APPEND it_recv.

ELSE.

  SELECT * FROM zmailmap INTO TABLE it_recv  WHERE filetype = file_type.


ENDIF.

      LOOP AT it_recv.
        TRANSLATE it_recv-mailid TO LOWER CASE.
        recipient = cl_cam_address_bcs=>create_internet_address(
       it_recv-mailid ).
        CALL METHOD send_request->add_recipient
          EXPORTING
            i_recipient  = recipient
            i_express    = 'U'
            i_copy       = ' '
            i_blind_copy = ' '
            i_no_forward = ' '.
      ENDLOOP.

***********Trigger e-mails immediately*****************************
      send_request->set_send_immediately( 'X' ).
      CALL METHOD send_request->send( ).

      COMMIT WORK.

    CATCH cx_document_bcs INTO bcs_exception.


  ENDTRY.



ENDFUNCTION.

Read only

Former Member
0 Likes
2,107

HI SMITHA RAO,

I am also having the same requirement like to send mail with attachment.

I dont have idea to configure the SCOT.

I f u dont mine can u send me ur code pls.

Its users urgent requirement.But no one is helping me.

I am facing lot of problems to complete that requirement.

My mail id is

goudjayasankar@yahoo.co.in

Madam,Pls help me.

I dont know how to configure the SCOT also.Pls tell me that one also.Here in my company even basis people they dont have idea to configure the SCOT. they were asking me to tell how to configure the SCOT.

At least pls send ur code .

Pls help me.

Thanks & Regards,

LOkesh.

Read only

Former Member
0 Likes
2,107

HI SMITHA RAO,

I am also having the same requirement like to send mail with attachment.

I dont have idea to configure the SCOT.

I f u dont mine can u send me ur code pls.

Its users urgent requirement.But no one is helping me.

I am facing lot of problems to complete that requirement.

My mail id is

goudjayasankar@yahoo.co.in

Madam,Pls help me.

I dont know how to configure the SCOT also.Pls tell me that one also.Here in my company even basis people they dont have idea to configure the SCOT. they were asking me to tell how to configure the SCOT.

At least pls send ur code .

Pls help me.

Thanks & Regards,

LOkesh.

Read only

0 Likes
2,107

Hi,

Thanks all. The problem has been resolved.

1. The data had to be converted to hex before adding the attachment to the document.

2. The file type had to be 'RAW' .

Lokesh,

The code has already been posted above.

To configure SCOT, follow the links provided by Sudheer and aRs.

Thanks,

Smitha.