09-02-2008 12:12 PM
hi friends,
can any one send me a sample program to send mail from SAP to Outlook with a text on body not at attachment.
Heading 1: note: i'm able to send the mail from SAP. but the problem is i need the text on the body of the mail and not as attachment.
please try to give me the exact reply.
thank you very much for visiting to my query.
09-02-2008 12:15 PM
09-02-2008 12:17 PM
Hello.
You have several options. The easiest if probably using FM EFG_GEN_SEND_EMAIL like:
TYPES: BEGIN OF ty_lines,
line TYPE char255,
END OF ty_lines.
DATA: ti_lines TYPE STANDARD TABLE OF ty_lines,
wa_lines TYPE ty_lines.
DATA: title TYPE string.
* APPEND LINES TO ti_lines (body) and add a title (subject)
CALL FUNCTION 'EFG_GEN_SEND_EMAIL'
EXPORTING
i_title = title
i_sender = <sender_email>
i_recipient = <receiver_email>
i_flg_commit = 'X'
i_flg_send_immediately = 'X'
TABLES
i_tab_lines = ti_lines
EXCEPTIONS
not_qualified = 1
failed = 2
OTHERS = 3.
Regards,
Valter Oliveira.
09-04-2008 10:51 AM
thank you Valter Oliveira .
but my requirement is to get the data in the mail body not in the attahment. i don't need any attachment. i just only need a simple mail with out attchment.
09-04-2008 10:55 AM
09-04-2008 10:56 AM
Hi again.
The FM I have mentioned doesn't use attachments .. I tested right now and received I_TAB_LINES data in the email body and title in subject.
Regards.
Valter Oliveira.
09-02-2008 12:20 PM
09-02-2008 12:22 PM
hai ,
make use of this code
&----
*& Form SEND_MAIL
&----
send email to current user *
----
FORM SEND_MAIL.
PARAMETERS FOR SO_NEW_DOCUMENT_SEND_API1
DATA: W_OBJECT_ID LIKE SOODK,
W_SONV_FLAG LIKE SONV-FLAG.
DATA: T_RECEIVERS LIKE SOMLRECI1 OCCURS 1 WITH HEADER LINE,
W_OBJECT_CONTENT LIKE SOLISTI1 OCCURS 1 WITH HEADER LINE,
W_DOC_DATA LIKE SODOCCHGI1 OCCURS 0 WITH HEADER LINE.
*
DATA: W_DATE(10).
CLEAR T_RECEIVERS.
T_RECEIVERS-RECEIVER = SY-UNAME.
T_RECEIVERS-REC_TYPE = 'B'.
T_RECEIVERS-EXPRESS = ' '.
APPEND T_RECEIVERS.
W_DOC_DATA-OBJ_DESCR = 'Change Expiry date'.
Delivery NO
CONCATENATE 'Delivery No' M_VMVMA-VBELN INTO W_OBJECT_CONTENT
SEPARATED BY ' '.
APPEND W_OBJECT_CONTENT.
material Batch
CONCATENATE 'Material' ZGREC-MATNR 'Batch' ZGREC-CHARG
INTO W_OBJECT_CONTENT SEPARATED BY ' '.
APPEND W_OBJECT_CONTENT.
Expiry date
WRITE B_VFDAT TO W_DATE DD/MM/YYYY.
CONCATENATE 'Change expiry date to' W_DATE
INTO W_OBJECT_CONTENT SEPARATED BY ' '.
APPEND W_OBJECT_CONTENT.
*
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
DOCUMENT_DATA = W_DOC_DATA
PUT_IN_OUTBOX = ' '
TABLES
OBJECT_CONTENT = W_OBJECT_CONTENT
RECEIVERS = T_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.
ENDFORM. " SEND_MAIL
09-02-2008 12:25 PM
Hello,
Please try the below code for your requirement.
data: send_request type ref to cl_bcs,
text type bcsy_text,
document type ref to cl_document_bcs,
sender type ref to cl_cam_address_bcs,
recipient type ref to cl_cam_address_bcs,
bcs_exception type ref to cx_bcs,
sent_to_all type os_boolean.
try.
send_request = cl_bcs=>create_persistent( ).
append 'Hi This is Test Mail' to text.
document = cl_document_bcs=>create_document(
i_type = 'RAW'
i_text = text
i_length = '7'
i_subject = 'hi' ).
send_request->set_document( document ).
sender = cl_cam_address_bcs=>create_internet_address(
'abc at xyz.com'
).
recipient = cl_cam_address_bcs=>create_internet_address(
'abc at xyz.com'
).
send_request->set_sender( sender ).
send_request->add_recipient(
exporting
i_recipient = recipient
i_express = 'X' ).
send_request->send(
exporting
i_with_error_screen = 'X'
receiving
result = sent_to_all ).
commit work.
catch cx_bcs into bcs_exception.
exit.
endtry.
09-02-2008 12:33 PM
Hi,
Try this code..
report yh_email1.
data: email type somlreci1-receiver value '<email id>'.
data: sender type soextreci1-receiver value 'SAPDEV02'.
data: imessage type standard table of solisti1 with header line,
iattach type standard table of solisti1 with header line,
ipacking_list like sopcklsti1 occurs 0 with header line,
ireceivers like somlreci1 occurs 0 with header line.
start-of-selection.
clear imessage. refresh imessage.
imessage = 'This is a mail from SAP ECC6'.
append imessage.
imessage = 'Thanks and Regards'.
append imessage.
imessage = 'Indu'.
append imessage.
perform send_email tables imessage
using email
'Mail from Indu'.
***********************************************************************
*
* Form SEND_EMAIL
***********************************************************************
*
form send_email tables pit_message
using email
p_mtitle.
data: xdocdata like sodocchgi1,
xcnt type i.
* Fill the document data.
xdocdata-doc_size = 1.
* Populate the subject/generic message attributes
xdocdata-obj_langu = sy-langu .
xdocdata-obj_name = 'SAPRPT' .
xdocdata-obj_descr = p_mtitle .
clear ipacking_list. refresh ipacking_list.
ipacking_list-transf_bin = space.
ipacking_list-head_start = 1.
ipacking_list-head_num = 0.
ipacking_list-body_start = 1.
describe table imessage lines ipacking_list-body_num.
ipacking_list-doc_type = 'RAW'.
append ipacking_list.
clear ireceivers.
refresh ireceivers.
ireceivers-receiver = email.
ireceivers-rec_type = 'U'.
append ireceivers.
call function 'SO_DOCUMENT_SEND_API1'
exporting
document_data = xdocdata
put_in_outbox = 'X'
sender_address = sender
commit_work = 'X'
tables
packing_list = ipacking_list
contents_txt = imessage
receivers = ireceivers
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.
*** These two statemnets are used to force the mail to send it to the
*receipeint otherwise we need to go to SOST tcode where we need to press
* F8 to send the mail to the other user. To avoid this we need to use
*these two statemnets. Here the mail is not in queue.
submit rsconn01 using selection-set 'INT' and return.
call function 'SO_DEQUEUE_UPDATE_LOCKS'.
* SUBMIT rsconn01 WITH mode = 'INT'
* WITH output = 'X'
* AND RETURN.
endform.
Regards
Indu
09-02-2008 12:47 PM
This program will allowed you to send email with attachment.
First, specify the attachment file from your local hardisk and execute.
Next, specify the sender email address and click the send button.
report y_cr17_mail.
data method1 like sy-ucomm.
data g_user like soudnamei1.
data g_user_data like soudatai1.
data g_owner like soud-usrnam.
data g_receipients like soos1 occurs 0 with header line.
data g_document like sood4 .
data g_header like sood2.
data g_folmam like sofm2.
data g_objcnt like soli occurs 0 with header line.
data g_objhead like soli occurs 0 with header line.
data g_objpara like selc occurs 0 with header line.
data g_objparb like soop1 occurs 0 with header line.
data g_attachments like sood5 occurs 0 with header line.
data g_references like soxrl occurs 0 with header line.
data g_authority like sofa-usracc.
data g_ref_document like sood4.
data g_new_parent like soodk.
data: begin of g_files occurs 10 ,
text(4096) type c,
end of g_files.
data : fold_number(12) type c,
fold_yr(2) type c,
fold_type(3) type c.
parameters ws_file(4096) type c default 'c:\debugger.txt'.
Can me any file fromyour pc ....either xls or word or ppt etc ...
g_user-sapname = sy-uname.
call function 'SO_USER_READ_API1'
exporting
user = g_user
PREPARE_FOR_FOLDER_ACCESS = ' '
importing
user_data = g_user_data
EXCEPTIONS
USER_NOT_EXIST = 1
PARAMETER_ERROR = 2
X_ERROR = 3
OTHERS = 4
.
if sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
endif.
fold_type = g_user_data-outboxfol+0(3).
fold_yr = g_user_data-outboxfol+3(2).
fold_number = g_user_data-outboxfol+5(12).
clear g_files.
refresh : g_objcnt,
g_objhead,
g_objpara,
g_objparb,
g_receipients,
g_attachments,
g_references,
g_files.
method1 = 'SAVE'.
g_document-foltp = fold_type.
g_document-folyr = fold_yr.
g_document-folno = fold_number.
g_document-objtp = g_user_data-object_typ.
*g_document-OBJYR = '27'.
*g_document-OBJNO = '000000002365'.
*g_document-OBJNAM = 'MESSAGE'.
g_document-objdes = 'sap-img.com testing by program'.
g_document-folrg = 'O'.
*g_document-okcode = 'CHNG'.
g_document-objlen = '0'.
g_document-file_ext = 'TXT'.
g_header-objdes = 'sap-img.com testing by program'.
g_header-file_ext = 'TXT'.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = sy-uname
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
FOLMEM_DATA =
RECEIVE_DATA =
.
File from the pc to send...
method1 = 'ATTCREATEFROMPC'.
g_files-text = ws_file.
append g_files.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header
.
method1 = 'SEND'.
g_receipients-recnam = 'MK085'.
g_receipients-recesc = 'B'.
g_receipients-sndex = 'X'.
append g_receipients.
call function 'SO_DOCUMENT_REPOSITORY_MANAGER'
exporting
method = method1
office_user = g_owner
ref_document = g_ref_document
new_parent = g_new_parent
importing
authority = g_authority
tables
objcont = g_objcnt
objhead = g_objhead
objpara = g_objpara
objparb = g_objparb
recipients = g_receipients
attachments = g_attachments
references = g_references
files = g_files
changing
document = g_document
header_data = g_header.
*-- End of Program
09-02-2008 12:51 PM
Hi,
I hope the following links will help you,
web logs like
and
http://www.sapdevelopment.co.uk/reporting/email/attach_xls.htm
Regards,
Harish
09-10-2008 6:29 AM
thank you for your help.
to get the text on the body of a mail.
we need to change the scot settings. in scot click on SMTP & change and set the internet settings. where we find output documents format and were we have to set the document output to TXT . that's it . problem solved.