Application Development and Automation 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: 
Read only

Send mail to internet address using SO_NEW_DOCUMENT_SEND_API1

Former Member
0 Likes
1,586

Hi all.

I want to use the FM: SO_NEW_DOCUMENT_SEND_API1 to send emails to internet address(e.g [email protected]), this function executes without exceptions but the mail is not sent.

I'm doing something like this:

DATA:

IT_I0105_DB TYPE STANDARD TABLE OF PA0105 WITH HEADER LINE,

IT_PA0032 TYPE STANDARD TABLE OF TY_PA0032 WITH HEADER LINE,

IT_DESTINO LIKE SOMLRECI1 OCCURS 1 WITH HEADER LINE,

IT_TEXTO LIKE SOLI OCCURS 10 WITH HEADER LINE,

IT_TITULO LIKE SODOCCHGI1 OCCURS 0 WITH HEADER LINE,

V_USNAME LIKE SY-UNAME,

V_NAME LIKE ESS_EMP-NAME,

V_SHORT LIKE P1000-SHORT,

V_STEXT LIKE P1000-STEXT,

V_EMPLEADO TYPE STRING,

V_UNIORG TYPE STRING,

V_UBICACION TYPE STRING,

V_EXTENSION TYPE STRING,

V_MAIL TYPE HRWPC_S_CONTACT-EMAIL.

  • Receiver

MOVE: V_MAIL TO IT_DESTINO-RECEIVER,

'U' TO IT_DESTINO-REC_TYPE,

' ' TO IT_DESTINO-EXPRESS.

APPEND IT_DESTINO.

  • Title

IT_TITULO-OBJ_NAME = 'EMAIL'.

IT_TITULO-OBJ_DESCR = 'PRUEBA DEL MAIL'.

APPEND IT_TITULO.

  • Content

IT_TEXTO-LINE = V_EMPLEADO.

APPEND IT_TEXTO.

IT_TEXTO-LINE = V_UBICACION.

APPEND IT_TEXTO.

IT_TEXTO-LINE = V_EXTENSION.

APPEND IT_TEXTO.

IT_TEXTO-LINE = P_PERIODO.

APPEND IT_TEXTO.

IT_TEXTO-LINE = V_UNIORG.

APPEND IT_TEXTO.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

DOCUMENT_DATA = IT_TITULO

DOCUMENT_TYPE = 'RAW'

PUT_IN_OUTBOX = ''

TABLES

OBJECT_CONTENT = IT_TEXTO

RECEIVERS = IT_DESTINO

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.

I dont know whats happening.

I hope somebody can helps me to solve my problem.

Thx

Regards.

Gregory

Hi all.

I want to use the FM: SO_NEW_DOCUMENT_SEND_API1 to send emails to internet address(e.g [email protected]), this function executes without exceptions but the mail is not sent.

I'm doing something like this:

DATA:

IT_I0105_DB TYPE STANDARD TABLE OF PA0105 WITH HEADER LINE,

IT_PA0032 TYPE STANDARD TABLE OF TY_PA0032 WITH HEADER LINE,

IT_DESTINO LIKE SOMLRECI1 OCCURS 1 WITH HEADER LINE,

IT_TEXTO LIKE SOLI OCCURS 10 WITH HEADER LINE,

IT_TITULO LIKE SODOCCHGI1 OCCURS 0 WITH HEADER LINE,

V_USNAME LIKE SY-UNAME,

V_NAME LIKE ESS_EMP-NAME,

V_SHORT LIKE P1000-SHORT,

V_STEXT LIKE P1000-STEXT,

V_EMPLEADO TYPE STRING,

V_UNIORG TYPE STRING,

V_UBICACION TYPE STRING,

V_EXTENSION TYPE STRING,

V_MAIL TYPE HRWPC_S_CONTACT-EMAIL.

  • Receiver

MOVE: V_MAIL TO IT_DESTINO-RECEIVER,

'U' TO IT_DESTINO-REC_TYPE,

' ' TO IT_DESTINO-EXPRESS.

APPEND IT_DESTINO.

  • Title

IT_TITULO-OBJ_NAME = 'EMAIL'.

IT_TITULO-OBJ_DESCR = 'PRUEBA DEL MAIL'.

APPEND IT_TITULO.

  • Content

IT_TEXTO-LINE = V_EMPLEADO.

APPEND IT_TEXTO.

IT_TEXTO-LINE = V_UBICACION.

APPEND IT_TEXTO.

IT_TEXTO-LINE = V_EXTENSION.

APPEND IT_TEXTO.

IT_TEXTO-LINE = P_PERIODO.

APPEND IT_TEXTO.

IT_TEXTO-LINE = V_UNIORG.

APPEND IT_TEXTO.

CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'

EXPORTING

DOCUMENT_DATA = IT_TITULO

DOCUMENT_TYPE = 'RAW'

PUT_IN_OUTBOX = ''

TABLES

OBJECT_CONTENT = IT_TEXTO

RECEIVERS = IT_DESTINO

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.

I dont know whats happening.

I hope somebody can helps me to solve my problem.

Thx

Regards.

Gregory

14 REPLIES 14
Read only

RichHeilman
Developer Advocate
Developer Advocate
0 Likes
1,533

Your code works good in my system. Have to sent the email using transaction SCOT?

Regards,

Rich Heilman

Read only

0 Likes
1,533

Thx Rich.

Yeap i'm using SCOT transaction to send the mail.

Regards.

Gregory.

Read only

0 Likes
1,533

So when executing your program, does it even show up in SCOT?

Regards,

Rich Heilman

Read only

0 Likes
1,533

No, when i execute the transaction SCOT it says: "No messages sent".

Thx

Gregory

Read only

0 Likes
1,533

Maybe your mail is waiting, then you have to send the process. If your admin sys does not create the job to send mail, you have to perform this step manualy

Regards

Frédéric

Read only

0 Likes
1,533

Well Frédéric, i'm trying to perform this step with the SCOT transaction, but this transaction says that there are no mails to send.

Thx n rgds.

Gregory.

Read only

0 Likes
1,533

Please i need help to solve the problems.

Thx n Rgds.

Gregory.

Read only

0 Likes
1,533

Can you send an email using standard SAP functionality (System->Short Message)? If that does not show up in SCOT either then you definetely have a system configuration problem.

Read only

0 Likes
1,533

Thx all i solve the problem. Set the import parameter COMMIT_WORK to 'X' did the work.

Now i see that the mail is sent with the mail cofigured in SU01 transaction. Is there any way to Set the 'FROM' attribute of the mail? If so, then i want to know it.

Or is there any other function that sends internet mail and let me set the 'FROM' attribute?

Regards.

Gregory.

Read only

0 Likes
1,533

Oh yes, I forgot about that. You must set the email address of the user which is doing the sending. You can not specify the sender programmically using the function module that you are. I have heard that you can do it if you are using SO_OBJECT_SEND. Which is called inside of the function module that you are using.

Regards,

Rich Heilman

Read only

0 Likes
1,533

Ok Rich, thx let me try.

rgds.

Gregory.

Read only

0 Likes
1,533

I try to use the FM 'SO_OBJECT_SEND' but i dont know which are the paramaters that i have to set to execute it.

Could somebody explain me where i say to the FM the Subject, the sender, the mail body... ???

I hope somebody can helps me.

Thx and rgds.

Grrgory.

Read only

0 Likes
1,533
Read only

0 Likes
1,533

Hey Jayanthi, thx for ur answer. I see the links and try to use the FM, but without success .

Mi issue is that i whant to pass the from address(the mail sender's) to the function.

Best regards.

Gregory.