<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: CL_CBS class - Set e-mail address in Application Development and Automation Discussions</title>
    <link>https://community.sap.com/t5/application-development-and-automation-discussions/cl-cbs-class-set-e-mail-address/m-p/5196614#M1202555</link>
    <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try this :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CLASS ca_sapuser_bcs     DEFINITION LOAD.
CLASS cl_cam_address_bcs DEFINITION LOAD.

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_bcs.
data: num_rows           type i.
DATA: textlength         type SO_OBJ_LEN.
DATA: l_mailtext         type BCSY_TEXT.
data: l_line(255)        type c value 'prima riga'.
data: sender_name        like sy-uname . "value 'sender name'.
data: mail_address       type string  value 'fixed_mail_address'.
data: MESSAGES           type REF TO CL_BSP_MESSAGES.
data: mail_title         type SO_OBJ_DES value 'Doc_title'.
* set direct update
*try.
*  CALL METHOD cl_os_system=&amp;gt;init_and_set_modes
*          EXPORTING i_update_mode     = oscon_dmode_direct
*                    i_external_commit = oscon_true.
*
*  catch cx_os.
*    if messages is not initial.
*      messages-&amp;gt;add_message( condition = 'mail'
*       message = 'Fehler beim Setzen des direkten Update aufgetreten' )
*.
*    endif.
*    exit.
*  endtry.

try.
* Create persistent send request
  send_request = cl_bcs=&amp;gt;create_persistent( ).

* Create document
  append l_line to l_mailtext.
  describe table l_mailtext lines num_rows.
  num_rows = num_rows * 255.
  move num_rows to textlength.
  document = cl_document_bcs=&amp;gt;create_document(
                      i_type    = 'RAW'
                      i_text    = l_mailtext
                      i_length  = textlength
                      i_subject = mail_title  ). "#EC *

* Add document to send request
  CALL METHOD send_request-&amp;gt;set_document( document ).

* Get sender object
*TRY.
"deve essere il nome di un sap user"
move sy-uname to sender_name.
CALL METHOD CL_SAPUSER_BCS=&amp;gt;CREATE
  EXPORTING
    I_USER = sender_name
  RECEIVING
    RESULT = sender
    .
* CATCH CX_ADDRESS_BCS .
*ENDTRY.


*  sender = cl_sapuser_bcs=&amp;gt;create( sy-uname ).

* Add sender
  CALL METHOD send_request-&amp;gt;set_sender
    EXPORTING i_sender = sender.

* Create recipient
  data: c_address TYPE ADR6-SMTP_ADDR.
  move mail_address to c_address.
  recipient = cl_cam_address_bcs=&amp;gt;create_internet_address(
                                            c_address ).

* Add recipient with its respective attributes to send request
  CALL METHOD send_request-&amp;gt;add_recipient
    EXPORTING
        i_recipient  = recipient
        i_express    = ' '
        i_copy       = ' '
        i_blind_copy = ' '.

* Send document
  CALL METHOD send_request-&amp;gt;send( ).

  COMMIT WORK.

  catch cx_bcs into bcs_exception.
    if messages is not initial.
      messages-&amp;gt;add_message( condition = 'mail'
       message =
       'Fehler beim Versenden der Mail aufgetreten' )."#EC NOTEXT

    endif.

    exit.

  endtry.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
    <pubDate>Fri, 13 Feb 2009 16:46:15 GMT</pubDate>
    <dc:creator>Former Member</dc:creator>
    <dc:date>2009-02-13T16:46:15Z</dc:date>
    <item>
      <title>CL_CBS class - Set e-mail address</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cl-cbs-class-set-e-mail-address/m-p/5196612#M1202553</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;I try to send a mail with CL_CBS class.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;I don't need to use the user mail but i have to set an external fixed e-mail address.&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Is it possible to do these with CL_CBS class ? and if is it possible how can I do?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;Thanks,&lt;/P&gt;&lt;P&gt;Michele Garofalo e Daniele Iadarola&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Feb 2009 16:00:40 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cl-cbs-class-set-e-mail-address/m-p/5196612#M1202553</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-13T16:00:40Z</dc:date>
    </item>
    <item>
      <title>Re: CL_CBS class - Set e-mail address</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cl-cbs-class-set-e-mail-address/m-p/5196613#M1202554</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;Are you looking for this ?&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;
          data: send_request       type ref to cl_bcs.
          move 'abc.abc.com' to it_recipient-smtp_addr.
          recipient = cl_cam_address_bcs=&amp;gt;create_internet_address(
  it_recipient-smtp_addr ).
          call method send_request-&amp;gt;add_recipient
            exporting
              i_recipient  = recipient
              i_express    = ' '
              i_copy       = ' '
              i_blind_copy = ' '
              i_no_forward = ' '.
&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;a®&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Feb 2009 16:11:27 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cl-cbs-class-set-e-mail-address/m-p/5196613#M1202554</guid>
      <dc:creator>former_member194669</dc:creator>
      <dc:date>2009-02-13T16:11:27Z</dc:date>
    </item>
    <item>
      <title>Re: CL_CBS class - Set e-mail address</title>
      <link>https://community.sap.com/t5/application-development-and-automation-discussions/cl-cbs-class-set-e-mail-address/m-p/5196614#M1202555</link>
      <description>&lt;HTML&gt;&lt;HEAD&gt;&lt;/HEAD&gt;&lt;BODY&gt;&lt;P&gt;try this :&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;P&gt;&lt;/P&gt;&lt;PRE&gt;&lt;CODE&gt;CLASS ca_sapuser_bcs     DEFINITION LOAD.
CLASS cl_cam_address_bcs DEFINITION LOAD.

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_bcs.
data: num_rows           type i.
DATA: textlength         type SO_OBJ_LEN.
DATA: l_mailtext         type BCSY_TEXT.
data: l_line(255)        type c value 'prima riga'.
data: sender_name        like sy-uname . "value 'sender name'.
data: mail_address       type string  value 'fixed_mail_address'.
data: MESSAGES           type REF TO CL_BSP_MESSAGES.
data: mail_title         type SO_OBJ_DES value 'Doc_title'.
* set direct update
*try.
*  CALL METHOD cl_os_system=&amp;gt;init_and_set_modes
*          EXPORTING i_update_mode     = oscon_dmode_direct
*                    i_external_commit = oscon_true.
*
*  catch cx_os.
*    if messages is not initial.
*      messages-&amp;gt;add_message( condition = 'mail'
*       message = 'Fehler beim Setzen des direkten Update aufgetreten' )
*.
*    endif.
*    exit.
*  endtry.

try.
* Create persistent send request
  send_request = cl_bcs=&amp;gt;create_persistent( ).

* Create document
  append l_line to l_mailtext.
  describe table l_mailtext lines num_rows.
  num_rows = num_rows * 255.
  move num_rows to textlength.
  document = cl_document_bcs=&amp;gt;create_document(
                      i_type    = 'RAW'
                      i_text    = l_mailtext
                      i_length  = textlength
                      i_subject = mail_title  ). "#EC *

* Add document to send request
  CALL METHOD send_request-&amp;gt;set_document( document ).

* Get sender object
*TRY.
"deve essere il nome di un sap user"
move sy-uname to sender_name.
CALL METHOD CL_SAPUSER_BCS=&amp;gt;CREATE
  EXPORTING
    I_USER = sender_name
  RECEIVING
    RESULT = sender
    .
* CATCH CX_ADDRESS_BCS .
*ENDTRY.


*  sender = cl_sapuser_bcs=&amp;gt;create( sy-uname ).

* Add sender
  CALL METHOD send_request-&amp;gt;set_sender
    EXPORTING i_sender = sender.

* Create recipient
  data: c_address TYPE ADR6-SMTP_ADDR.
  move mail_address to c_address.
  recipient = cl_cam_address_bcs=&amp;gt;create_internet_address(
                                            c_address ).

* Add recipient with its respective attributes to send request
  CALL METHOD send_request-&amp;gt;add_recipient
    EXPORTING
        i_recipient  = recipient
        i_express    = ' '
        i_copy       = ' '
        i_blind_copy = ' '.

* Send document
  CALL METHOD send_request-&amp;gt;send( ).

  COMMIT WORK.

  catch cx_bcs into bcs_exception.
    if messages is not initial.
      messages-&amp;gt;add_message( condition = 'mail'
       message =
       'Fehler beim Versenden der Mail aufgetreten' )."#EC NOTEXT

    endif.

    exit.

  endtry.&lt;/CODE&gt;&lt;/PRE&gt;&lt;P&gt;&lt;/P&gt;&lt;/BODY&gt;&lt;/HTML&gt;</description>
      <pubDate>Fri, 13 Feb 2009 16:46:15 GMT</pubDate>
      <guid>https://community.sap.com/t5/application-development-and-automation-discussions/cl-cbs-class-set-e-mail-address/m-p/5196614#M1202555</guid>
      <dc:creator>Former Member</dc:creator>
      <dc:date>2009-02-13T16:46:15Z</dc:date>
    </item>
  </channel>
</rss>

