cancel
Showing results for 
Search instead for 
Did you mean: 

Multiple Mail sending

Former Member
0 Kudos

Hello Experts,

I am using a function module to send mails , i m able to send mail to single email id but when i try to send mail to multiple emailid

using structure SOMRECI1 programme executes but m not getting mails..... following is my code

TABLES : ZTOMAIL .

TYPES : BEGIN OF TY_TOMAIL,

TMAIL TYPE AD_SMTPADR,

END OF TY_TOMAIL.

DATA : IT_EMAILS TYPE STANDARD TABLE OF SOMLRECI1 ,

TO_MAIL TYPE STANDARD TABLE OF SOMLRECI1 ,

wa_tmail TYPE SOMLRECI1,

  • TO_MAIL TYPE STANDARD TABLE OF TY_TOMAIL ,

WA_MAIL TYPE ADR6-SMTP_AdDR,

wa TYPE c LENGTH 100,

WA_FMAIL TYPE ADR6-SMTP_ADDR,

IT_MAIL TYPE STANDARD TABLE OF SOMLRECI1 WITH HEADER LINE.

DATA : TOEMAIL TYPE ADR6-SMTP_ADDR,

FROMEMAIL TYPE ADR6-SMTP_ADDR ,

SUB TYPE SO_OBJ_DES,

RET TYPE SY-SUBRC,

I_TXT TYPE BCSY_TEXT OCCURS 0,

IT_TEXT TYPE BCSY_TEXT.

WA = ' CHECK WHEATHER SENT ON ALL MAIL OR NOT'.

APPEND WA TO IT_TEXT.

*

*SELECT RECEIVER REC_TYPE COM_TYPE FROM ZTOMAIL INTO TABLE to_MAIL.

*

wa_tMAIL-RECEIVER = 'reciever mail id1'.

wa_tMAIL-REC_TYPE = 'U'.

wa_tMAIL-COM_TYPE = 'INT'.

wa_tMAIL-NOTIF_DEL = 'X'.

wa_tMAIL-NOTIF_NDEL = 'X'.

APPEND wa_tMAIL to TO_MAIL.

wa_tMAIL-RECEIVER = 'reciever mail id2'.

wa_tMAIL-REC_TYPE = 'U'.

wa_tMAIL-COM_TYPE = 'INT'.

wa_tMAIL-NOTIF_DEL = 'X'.

wa_tMAIL-NOTIF_NDEL = 'X'.

APPEND wa_tMAIL to TO_MAIL.

WA_FMAIL = 'sender mail id'.

SUB = 'this mail is to check '.

CALL FUNCTION 'Z_SENDMAIL'

EXPORTING

FROMEMAIL = WA_FMAIL

  • TOEMAIL = wa_mail

SUBJECT = SUB

FLAG = 'X'

IMPORTING

RETURN_CODE = RET

TABLES

IT_TEXT = IT_TEXT

IT_EMAILS = TO_MAIL

.

iF SY-SUBRC = 0.

WRITE 😕 'done'.

ENDIF.

Accepted Solutions (0)

Answers (5)

Answers (5)

Former Member
0 Kudos

Hi,

Check the threshhold limit in getting the TOO_MANY_RECEIVERS exception. If it work well for 50 mail id's and fails for 51 mail id's, then you can find the no. of records in the internal table TO_MAIL and use the FM 'SO_DOCUMENT_SEND_API1' passing the chunks of receivers limiting to 50 or 45 each time.

Regards,

Satish Kanteti

Former Member
0 Kudos

THANK YOU ALL FOR YOUR REPLIES, NOW MY PROBLEM IS WHEN I SEND TO SINGLE ID IN SOST IN GET ITS STATUS SENT

BUT FOR MORE THAN ONE EVEN FOR 3-4 MAIL IDS IT SOST SHOWS ME WAITING STATUS..

Former Member
0 Kudos

Hi,

You can use the standard program RSCONN01 which forces to send the external mail immediately.

SUBMIT RSCONN01 WITH mode = 'INT'

WITH output = 'X'

AND RETURN.

Use this logic after all the mails has been created.

Regards,

Satish Kanteti

former_member203305
Active Contributor
0 Kudos

Hi,

check this code:

the it table contains all the email address. it shoud work


data: it_reclist  TYPE TABLE OF somlreci1,
        wa_reclist  TYPE somlreci1,
  
LOOP AT it.
    CLEAR: wa_reclist.
    wa_reclist-receiver = it-recextnam.
    wa_reclist-rec_type = 'U'.
    wa_reclist-express = 'X'.
    APPEND wa_reclist TO it_reclist.
  ENDLOOP.

  CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
    EXPORTING
      document_data              = wa_doc_chng
      put_in_outbox              = 'X'
      commit_work                = 'X'
    TABLES
      packing_list               = it_objpack[]
      contents_txt               = it_objtxt[]
      receivers                  = it_reclist[]

Regards

Former Member
0 Kudos

Hi Sagar,

I think FM z_sendmail is used in your project, inside this FM they might have called standrad FM SO_DOCUMENT_SEND_API1.

do one thing.

Collect all the information like mail id, subject, text,domian in one internal table i.e it_mail and use the above FM like the below

loop at it_mail.

CALL FUNCTION 'Z_SENDMAIL'

EXPORTING

TOEMAIL = it_mail-emailid

SUBJECT = it_mail-subject

DOMAIN = it_mail-domain

TABLES

IT_TEXT = IT_TEXT

endloop.

store the content in it_text and pass it to the table.

Hope this will helps you.

Regards,

Kiran

Former Member
0 Kudos

Try using the standard Function Module SO_DOCUMENT_SEND_API1, it will definitly send mail to multiple ID's.

Not sure about the logic used in your Z Function module.

Former Member
0 Kudos

Hi,

Why ar eyou using Z FM for sending emails and not the standard SAP FM SO_DOCUMENT_SEND_API1 ?

Former Member
0 Kudos

thanks alot , now when i using so_document_send_api1 i m getting this error Error in calling 'SBCOMS_SEND_REQUEST_CREATE' in 'SO_DOCUMENT_SEND_API1' with Sy-subcr = 1".

Former Member
0 Kudos

How many e-mail are you passing to the FM? Cause the problem seems to be TOO_MANY_RECEIVERS

brad_bohn
Active Contributor
0 Kudos

Why ar eyou using Z FM for sending emails and not the standard SAP FM SO_DOCUMENT_SEND_API1 ?

It may be 'standard' but it's outdated. Don't recommend it to posters if they can use CL_BCS...