cancel
Showing results for 
Search instead for 
Did you mean: 

issue with classes to send email

Former Member
0 Kudos

Hi guyz,

My requirement is to send smartform as an email as attachment in pdf format , I done it using function module SO_NEW_DOCUMENT_ATT_SEND_API1 , but the problem of using that is I cannot change senders email id. so now I chose the option to use classes , I have a code to send email with data in the email body, I also need to add smartform as an attachment in pdf format to email.How to get this...please advise...

Thanks in advance

Regards

Edited by: BrightSide on Jan 7, 2010 10:45 AM

Accepted Solutions (0)

Answers (2)

Answers (2)

former_member156446
Active Contributor
0 Kudos

after CALL FUNCTION 'SX_OBJECT_CONVERT_OTF_PDF'

CALL METHOD l_email->set_subject
      EXPORTING
        subject = v_subject.

*   Set the message
    CALL METHOD l_email->set_message
      EXPORTING
        text = i_content
        type = zcl_email_message=>doc_type_text.

    CALL METHOD l_email->add_attachment
      EXPORTING
        contents_bin = i_attach_raw
        name         = lv_name
        type         = 'BIN'.


      CALL METHOD l_email->add_to
        EXPORTING
          address = i_rec.  " fill i_rec with email id's u want to send the email.

*   Send the e-mail.
    CALL METHOD l_email->send
      EXPORTING
        commit_work = space
      EXCEPTIONS
        send_error  = 1
        OTHERS      = 2.

martin_voros
Active Contributor
0 Kudos

Hi,

similar questions as yours have been answered multiple times here on SDN. Use search functionality to look for answer before posting your question. I remember that there is a nice blog from Thomas Jung about using classes to send an email. How to convert spool request to pdf file can also be easily found here.

Cheers

Former Member
0 Kudos

hello,

I have done it but cant find . That is why I posted here.

Thanks

martin_voros
Active Contributor
0 Kudos

Hi,

[here|/people/thomas.jung3/blog/2004/09/08/sending-e-mail-from-abap--version-610-and-higher--bcs-interface] is the mentioned blog by Thomas Jung. From taht example you can see that class CL_DOCUMENT_BCS has method add_attachment. You can attach any binary data using parameter I_ATT_CONTENT_HEX which is table with 255 bytes long lines. So you need to convert your form to PDF and then convert it to this format. [Here|http://wiki.sdn.sap.com/wiki/display/Snippets/ConvertSmartformtoPDFformat] is an example of converting smartform to PDF.

Cheers