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

How to send Mail without attachment using SO_OBJECT_SEND?

Former Member
0 Likes
2,206

Hi,

In one of my report,we used SO_OBJECT_SEND for sending mails with PDF attachement.

What parameter,should i comment so that mail goes without attachment?

For contents of attachment ,we have used standard text SO10 .

awaiting for your valuable input

Regards,

Rachel

Hi,

In one of my report,we used SO_OBJECT_SEND for sending mails with PDF attachement.

What parameter,should i comment so that mail goes without attachment?

For contents of attachment ,we have used standard text SO10 .

awaiting for your valuable input

Regards,

Rachel

5 REPLIES 5
Read only

Former Member
0 Likes
1,133

Hi,

To send mail w/o an attachment, use this FM;-

SO_NEW_DOCUMENT_SEND_API1

Let me know if u need any other clarification abt this FM

Regards,

Kanika

Read only

Former Member
0 Likes
1,133

HI,

Coment the att_cont variable of the FM and attachement details in Packing list

Check the highlighted the lines in bold char

Example

CALL FUNCTION 'QCE1_CONVERT'

TABLES

t_source_tab = l_otfdata_tab1

t_target_tab = l_objbin

EXCEPTIONS

convert_not_possible = 1

OTHERS = 2.

Add the Email Body to MAIL_CONTENT table

MOVE 'Thank you for your order' TO mail_content-line.

APPEND mail_content.

MOVE 'See attached PDF for your Order Confirmation' TO mail_content-line.

APPEND mail_content.

packing_list-transf_bin = 'X'.

packing_list-head_start = 1.

packing_list-head_num = 2.

packing_list-body_start = 1.

DESCRIBE TABLE l_objbin[] LINES packing_list-body_num.

packing_list-body_num = 9999.

packing_list-objtp = 'PDF'.

packing_list-objnam = 'Order Confirmation'.

packing_list-OBJDES = 'Order Confirmation'.

packing_list-file_ext = 'PDF'.

APPEND packing_list.

CLEAR packing_list

CALL FUNCTION 'SO_OBJECT_SEND'

EXPORTING

object_hd_change = tsood1

object_type = 'RAW'

TABLES

objcont = mail_content

objcont = l_objbin

receivers = receivers

att_cont = l_objbin

packing_list = packing_list

note_text = mail_content

EXCEPTIONS

active_user_not_exist = 1

communication_failure = 2

component_not_available = 3

folder_not_exist = 4

folder_no_authorization = 5

forwarder_not_exist = 6

note_not_exist = 7

object_not_exist = 8

object_not_sent = 9

object_no_authorization = 10

object_type_not_exist = 11

operation_no_authorization = 12

owner_not_exist = 13

parameter_error = 14

substitute_not_active = 15

substitute_not_defined = 16

system_failure = 17

too_much_receivers = 18

user_not_exist = 19

x_error = 20

originator_not_exist = 21

OTHERS = 22.

Read only

Former Member
0 Likes
1,133

REPORT zsendemail .

PARAMETERS: psubject(40) type c default 'Hello',

p_email(40) type c default 'WRITE EMAIL ID' .

data: it_packing_list like sopcklsti1 occurs 0 with header line,

it_contents like solisti1 occurs 0 with header line,

it_receivers like somlreci1 occurs 0 with header line,

it_attachment like solisti1 occurs 0 with header line,

gd_cnt type i,

gd_sent_all(1) type c,

gd_doc_data like sodocchgi1,

gd_error type sy-subrc.

data: it_message type standard table of SOLISTI1 initial size 0

with header line.

***********************************************************************

*START-OF-SELECTION.

START-OF-SELECTION.

Perform populate_message_table.

*Send email message, although is not sent from SAP until mail send

*program has been executed(rsconn01)

PERFORM send_email_message.

*Instructs mail send program for SAPCONNECT to send email(rsconn01)

perform initiate_mail_execute_program.

&----


*& Form POPULATE_MESSAGE_TABLE

&----


  • Adds text to email text table

----


form populate_message_table.

Append 'Email line 1' to it_message.

Append 'Email line 2' to it_message.

Append 'Email line 3' to it_message.

Append 'Email line 4' to it_message.

endform. " POPULATE_MESSAGE_TABLE

&----


*& Form SEND_EMAIL_MESSAGE

&----


  • Send email message

----


form send_email_message.

  • Fill the document data.

gd_doc_data-doc_size = 1.

  • Populate the subject/generic message attributes

gd_doc_data-obj_langu = sy-langu.

gd_doc_data-obj_name = 'SAPRPT'.

gd_doc_data-obj_descr = psubject.

gd_doc_data-sensitivty = 'F'.

  • Describe the body of the message

clear it_packing_list.

refresh it_packing_list.

it_packing_list-transf_bin = space.

it_packing_list-head_start = 1.

it_packing_list-head_num = 0.

it_packing_list-body_start = 1.

describe table it_message lines it_packing_list-body_num.

it_packing_list-doc_type = 'RAW'.

append it_packing_list.

  • Add the recipients email address

clear it_receivers.

refresh it_receivers.

it_receivers-receiver = p_email.

it_receivers-rec_type = 'U'.

it_receivers-com_type = 'INT'.

it_receivers-notif_del = 'X'.

it_receivers-notif_ndel = 'X'.

append it_receivers.

  • Call the FM to post the message to SAPMAIL

call function 'SO_NEW_DOCUMENT_ATT_SEND_API1'

exporting

document_data = gd_doc_data

put_in_outbox = 'X'

importing

sent_to_all = gd_sent_all

tables

packing_list = it_packing_list

contents_txt = it_message

receivers = it_receivers

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.

  • Store function module return code

gd_error = sy-subrc.

  • Get it_receivers return code

loop at it_receivers.

endloop.

endform. " SEND_EMAIL_MESSAGE

&----


*& Form INITIATE_MAIL_EXECUTE_PROGRAM

&----


  • Instructs mail send program for SAPCONNECT to send email.

----


form initiate_mail_execute_program.

wait up to 2 seconds.

if gd_error eq 0.

submit rsconn01 with mode = 'INT'

with output = 'X'

and return.

endif.

endform. " INITIATE_MAIL_EXECUTE_PROGRAM

Read only

Former Member
0 Likes
1,133

Read only

Former Member
0 Likes
1,133

I cannot use another function moduleSO_NEW_DOCUMENT_SEND_API1,coz lot of changes will be involved.

hence by using 'SO_OBJECT_SEND' how to send mails without attachment.

As per avinash suggestions I have commented att_cont ,but even then mails is going with attachment.

aslo from the below code u can see i am not using packing_list.

CALL FUNCTION 'SO_OBJECT_SEND'

EXPORTING

object_hd_change = x_object_hd_change " document title ( scot title)

  • object_type = document_type " pdf

owner = sy-uname

IMPORTING

sent_to_all = x_sent_to_all

TABLES

objcont = x_objcont

objhead = x_objhead

receivers = x_receivers

  • att_cont = x_attcont

note_text = x_note

EXCEPTIONS

active_user_not_exist = 1

communication_failure = 2

component_not_available = 3

folder_not_exist = 4

folder_no_authorization = 5

forwarder_not_exist = 6

note_not_exist = 7

object_not_exist = 8

object_not_sent = 9

object_no_authorization = 10

object_type_not_exist = 11

operation_no_authorization = 12

owner_not_exist = 13

parameter_error = 14

substitute_not_active = 15

substitute_not_defined = 16

system_failure = 17

too_much_receivers = 18

user_not_exist = 19

x_error = 20

OTHERS = 21.

Regards,

Rachel