cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

send mail delayed

EnnoWulff
Active Contributor
1,340

Hey Community!

Is there a way to send a mail to a specified time using CL_BCS?

I did not find any hint where to set a time when the mail should be sent.

Yes, I know, I can program a job that starts to that time and sends the mail, but I wonder if there is a built-in way for this.

Thanks for any hints

~Enno

Accepted Solutions (1)

Accepted Solutions (1)

Ryan-Crosby
Active Contributor

You could try the following but you'd also have to put in work to generate the timestamp for a future date/time and the domain definition suggests UTC.  Please note that I believe the normal way would be to call the SEND_SCREEN method which appears to allow a user to input such information.

  DATA: email    TYPE REF TO cl_bcs,
        exc      TYPE REF TO cx_bcs.

* Generate one in the future for true delay
  GET TIME STAMP FIELD DATA(timestamp).

  TRY.
*   Generate send request
    email = cl_bcs=>create_persistent( ).
    email->send_request->set_send_at( timestamp ).

*   Create and set document
    ...

*   Create sender and recipient addresses
    ...

*   Send document
    DATA(sent) = email->send( ).
    IF sent IS NOT INITIAL.
      COMMIT WORK.
    ELSE.
      ROLLBACK WORK.
    ENDIF.

    CATCH cx_bcs INTO exc.
*     No email sent - do nothing here
  ENDTRY.

 

Regards,
Ryan Crosby

EnnoWulff
Active Contributor
Cool! Thanks @Ryan-Crosby! That looks promising! I will try this
Ryan-Crosby
Active Contributor
@EnnoWulff let me know if it works...
EnnoWulff
Active Contributor
@Ryan-Crosby it works! Thanks a lot!
RaymondGiuseppi
Active Contributor
I will try this option, which I wasn't aware of.

Answers (1)

Answers (1)

RaymondGiuseppi
Active Contributor

As far as I'm aware, this isn't something you can do with CL_BCS. You can easily submit a background delayed job, working with SOST/SCOT tables is risky and more difficult.

EnnoWulff
Active Contributor
0 Likes
Thanks for the confirmation, @RaymondGiuseppi !