Application Development Discussions
Join the discussions or start your own on all things application development, including tools and APIs, programming models, and keeping your skills sharp.
cancel
Showing results for 
Search instead for 
Did you mean: 

fm SO_NEW_DOCUMENT_SEND_API1

Former Member
0 Kudos

hi everybody

im using fm SO_NEW_DOCUMENT_SEND_API1 to send mail,

i have 2 receivers, the mail is being sent properly but the sender is getting the mails twice in his mailbox

there are 2 receivers and 1 sender

the sender should receive the mail once, isnt it?

heres my code

concatenate '9118' '@email.net' into mailrec-receiver.

mailrec-rec_type = 'U'.

append mailrec.

concatenate '9808' '@email.net' into mailrec-receiver.

mailrec-rec_type = 'U'.

append mailrec.

loop at mailrec.

call function 'SO_NEW_DOCUMENT_SEND_API1'

exporting

document_data = maildata

document_type = 'RAW'

put_in_outbox = 'X'

tables

object_header = mailtxt

object_content = mailtxt

receivers = mailrec

exceptions

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

others = 8.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

is my code wrong?

1 ACCEPTED SOLUTION

Former Member
0 Kudos

Hi

The following code will work properly and sending the mail twice as u have used loop at mailrec.So Mail has been sent two times thats why sender has two mails in sent items.

Just remove loop and endloop from ur code and execute

that will work

Or try this

U can try like this

concatenate '9118''@email.net' into mailrec1-receiver1.

concatenate '9808''@email.net' into mailrec-receiver2.

concatenate mailrec1-receiver1 mailrec-receiver2 into mailrec-receiver separeted by ';'.

mailrec-rec_type = 'U'.

append mailrec.

then

call function 'SO_NEW_DOCUMENT_SEND_API1'

exporting

document_data = maildata

document_type = 'RAW'

put_in_outbox = 'X'

tables

object_header = mailtxt

object_content = mailtxt

receivers = mailrec

exceptions

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

others = 8.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

I think it should work

just correct syntax errors.

If helpful reward points

Regs

Manas Ranjan Panda

Message was edited by: MANAS PANDA

7 REPLIES 7

former_member188685
Active Contributor
0 Kudos

Hi,

there is nothing wrong in your code.

i guess in your outbox you are able to see two mails separately is it so.

since you are sending it to two peoples, you will see two mails in your out box.

Regards

vijay

0 Kudos

is there a way to receive it only once in the sender's outbox?

because the user wants the email to appear only once in the sender's outbox, can that be done?

anversha_s
Active Contributor
0 Kudos

hi,

just refresh the internal table <b>mailrec</b> before

the appending of mail id's

rgds

anver

Former Member
0 Kudos

hi sia,

the problem is, that you loop?

in the FM there is the table mailrec with 2 receiver

and you execute the FM 2 times.

You don't have to loop!

Regards, Dieter

Former Member
0 Kudos

Hi

The following code will work properly and sending the mail twice as u have used loop at mailrec.So Mail has been sent two times thats why sender has two mails in sent items.

Just remove loop and endloop from ur code and execute

that will work

Or try this

U can try like this

concatenate '9118''@email.net' into mailrec1-receiver1.

concatenate '9808''@email.net' into mailrec-receiver2.

concatenate mailrec1-receiver1 mailrec-receiver2 into mailrec-receiver separeted by ';'.

mailrec-rec_type = 'U'.

append mailrec.

then

call function 'SO_NEW_DOCUMENT_SEND_API1'

exporting

document_data = maildata

document_type = 'RAW'

put_in_outbox = 'X'

tables

object_header = mailtxt

object_content = mailtxt

receivers = mailrec

exceptions

too_many_receivers = 1

document_not_sent = 2

document_type_not_exist = 3

operation_no_authorization = 4

parameter_error = 5

x_error = 6

enqueue_error = 7

others = 8.

if sy-subrc <> 0.

  • MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO

  • WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.

endif.

I think it should work

just correct syntax errors.

If helpful reward points

Regs

Manas Ranjan Panda

Message was edited by: MANAS PANDA

0 Kudos

Thanks for ur replies!

Former Member
0 Kudos

Hi anjali,

Remove the loop at mailrec.

the mailrec internal table will have the mail ids of the receiver so you need not to loop this internal table to send the mail to each receiver.

The FM it self will send the mail to all the receiver which are populated in this internal table.

Hope this will work.

Regards,

Satya