Skip to Content
avatar image
Former Member

Changing the Sender Address while sending the form output to external mail

Hi friends,

I have to change the sender address while sending the form output to a mail. Currently the sender address is coming from the current user master. I need to change that sender address to a specific mail id say 'test@test.com'. Please let me know if any one of you have done this.

Thanx in advance,

Ram

Add comment
10|10000 characters needed characters exceeded

  • Get RSS Feed

4 Answers

  • avatar image
    Former Member
    May 23, 2007 at 05:35 AM

    then u have to change parameters of FM.

    Regards

    Peram

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    May 23, 2007 at 06:46 AM

    Hello Ram,

    I supposed for this you should be using the FM CREATE_SENDER_OBJECT_PPF.

    If so, in the exposrting parameter ip_sender, you just need to pass the new mail of the sender.

    If you are not using this FM, you can add the FM just before sending the mail code.

    Regards,

    Zaheed

    Add comment
    10|10000 characters needed characters exceeded

    • Former Member

      Hi Zaheed,

      The sender parameter to the function module CREATE_SENDER_OBJECT_PPF should be an SAP User ID existing. But I want to assign the sender mail id (ex: test@test.com) which is not relevant to any SAP User ID. How can I pass that mail ID?

      Ram

  • avatar image
    Former Member
    Jul 16, 2007 at 10:38 PM

    Hello Ram,

    I am facing that same situation. Have you got the solution? Could you please post it?

    Thank you!

    Karla.

    Add comment
    10|10000 characters needed characters exceeded

  • avatar image
    Former Member
    Jul 16, 2007 at 11:36 PM

    When sending using Communication Services (CL_BCS) you can set Sender to an address that does not exist in SAP, and also set "Reply To" address to a different value if you wish.

    See following code:

    Andrew

    =======================

    &----


    *& Report ZLOCAL_EMAIL_TEST

    *&

    &----


    *

    • Test of ECC Send email using class CL_BCS

    *

    &----


    REPORT zlocal_email_test.

    DATA:

    l_obj TYPE REF TO cl_bcs,

    l_recip TYPE REF TO if_recipient_bcs,

    l_rec TYPE REF TO cl_cam_address_bcs,

    sender TYPE REF TO if_sender_bcs,

    note TYPE bcsy_text,

    line TYPE soli,

    l_address TYPE adr6-smtp_addr,

    l_result TYPE os_boolean,

    l_sub TYPE string,

    text TYPE bcsy_text,

    document TYPE REF TO cl_document_bcs.

    parameters: p_email like ADR6-SMTP_ADDR visible length 70,

    p_send like ADR6-SMTP_ADDR visible length 70,

    p_uname like sy-uname default sy-uname.

    START-OF-SELECTION.

    • Create email instance

    l_obj = cl_bcs=>create_persistent( ).

    • Build text of message

    APPEND 'Hello World' TO text.

    APPEND 'Hello World 2' TO text.

    APPEND 'Hello World 3' TO text.

    APPEND 'Hello World 4' TO text.

    • Create the email document

    CALL METHOD cl_document_bcs=>create_document

    EXPORTING

    i_type = 'RAW'

    i_subject = 'subject line'

    • I_LENGTH =

    • I_LANGUAGE = SPACE

    • I_IMPORTANCE =

    • I_SENSITIVITY =

    i_text = text

    • I_HEX =

    • I_HEADER =

    • I_SENDER =

    RECEIVING

    result = document.

    • Add document to email object

    CALL METHOD l_obj->set_document

    EXPORTING

    i_document = document.

    • Short form version

    • CALL METHOD l_obj->set_document( document ).

    • Build long subject line

    CONCATENATE 'Long subject' sy-abcde 'with still more'

    'Long subject' sy-abcde 'with still more'

    'Long subject' sy-abcde 'with still more'

    INTO l_sub SEPARATED BY space.

    • Add long subject to the email

    CALL METHOD l_obj->set_message_subject

    EXPORTING

    ip_subject = l_sub.

    • Get recipient address in correct format

    CALL METHOD cl_cam_address_bcs=>create_internet_address

    EXPORTING

    i_address_string = p_email

    RECEIVING

    result = l_rec.

    • Add recipient address to the email

    CALL METHOD l_obj->add_recipient

    EXPORTING

    i_recipient = l_rec

    i_express = 'X'.

    • Get Sender address in correct format for Internet email

    CALL METHOD cl_cam_address_bcs=>create_internet_address

    EXPORTING

    i_address_string = p_send

    RECEIVING

    result = sender.

    • Get Sender address in correct format for SAP User

    • CALL METHOD cl_sapuser_bcs=>create

    • EXPORTING

    • i_user = p_uname

    • RECEIVING

    • result = sender.

    • Short form version of this method call

    • sender = cl_sapuser_bcs=>create( p_uname ).

    • Add sender to the email

    CALL METHOD l_obj->set_sender

    EXPORTING

    i_sender = sender.

    • Send the email

    CALL METHOD l_obj->send

    • EXPORTING

    • I_WITH_ERROR_SCREEN = SPACE

    RECEIVING

    result = l_result.

    • Required commit work.

    COMMIT WORK.

    *

    Add comment
    10|10000 characters needed characters exceeded