Send mail by attaching a pdf fetching data from tables.
Dear Team,
I have a requirement to send a mail by attaching a pdf.
Step1 : Getting the data fron tables based on some logic into internal tables. [DONE]
Step2 : Using this internal and making a pdf [At present I am making an excel sheet, But client requires non editable well formatted pdf]
Step3 : Attach this PDF and send it as a mail. [At present I am sending the attched excel but want to send pdf]
Sample code used is
** Body of the mail
WA_TEXT-LINE = 'Note : This is an autogenerated mail. Please do not reply to this mail.'.
APPEND WA_TEXT TO TEXT.
CLEAR WA_TEXT.
* create document from internal table with text
DOCUMENT = CL_DOCUMENT_BCS=>CREATE_DOCUMENT(
I_TYPE = 'RAW'
I_TEXT = TEXT
I_LENGTH = '12'
I_SUBJECT = I_SUBJECT1 ).
** Excel Attachemnt
*** Preparing the xcel
CONCATENATE 'SNO' 'Request' 'Data1' INTO WA_TEXT-LINE SEPARATED BY CON_TAB.
CONCATENATE CON_CRET WA_TEXT-LINE INTO WA_TEXT-LINE.
APPEND WA_TEXT TO TEXT.
CLEAR WA_TEXT.
CONCATENATE WA_SNO WA_REQUEST WA_DATA1 INTO WA_TEXT-LINE SEPARATED BY CON_TAB.
CONCATENATE CON_CRET WA_TEXT-LINE INTO WA_TEXT.
APPEND WA_TEXT TO TEXT.
CLEAR : WA_TEXT, TEMP_TYPE .
*** Attaching the excel
DATA : COUNTER TYPE I.
DESCRIBE TABLE TEXT LINES COUNTER.
LOOP AT TEXT INTO WA_TEXT.
SIZE = 255 + STRLEN( WA_TEXT-LINE ) + SIZE .
ENDLOOP.
CALL METHOD DOCUMENT->ADD_ATTACHMENT
EXPORTING
I_ATTACHMENT_TYPE = 'XLS'
I_ATTACHMENT_SUBJECT = I_SUBJECT
I_ATTACHMENT_SIZE = SIZE
I_ATT_CONTENT_TEXT = TEXT.
** Semding Mail
CALL METHOD SEND_REQUEST->SET_DOCUMENT( DOCUMENT ).
IF REQUESTER_MAIL IS NOT INITIAL.
* create recipient for cc
RECIPIENT = CL_CAM_ADDRESS_BCS=>CREATE_INTERNET_ADDRESS(
I_ADDRESS_STRING = REQUESTER_MAIL ).
* add recipient with its respective attributes to send request
CALL METHOD SEND_REQUEST->ADD_RECIPIENT
EXPORTING
I_RECIPIENT = RECIPIENT
I_COPY = 'X'
I_EXPRESS = 'X'.
ENDIF.
SEND_REQUEST->SET_SEND_IMMEDIATELY('X').
* ---------- send document ---------------------------------------
CALL METHOD SEND_REQUEST->SEND(
EXPORTING
I_WITH_ERROR_SCREEN = 'X'
RECEIVING
RESULT = SENT_TO_ALL ).
IF SENT_TO_ALL = 'X'.
WRITE TEXT-003.
ENDIF.
COMMIT WORK.
Please help me in this regard.
Thanks in advance.
Sai
Hi,
You can convert the data into spool and then pdf,
please go through this link in this data from an internal
table of an script or an smartform is converted into spool
and then sended into mail,
https://wiki.sdn.sap.com/wiki/display/sandbox/ConversionofSpoolRequestDataintoPDFandExcelFormatandSenditintoMail
Hope it helps
Regards
Mansi
Similar Messages
-
Fetch data from table and generate attachment than mail it.
Hello Experts,
From couple of day I am searching on Google for a better database procedure that will help me to get data from tables and generate attachment and mail it but i fail.
My Scenario is:
I have a query that will fetch almost 5000 records from database tables. Each record has almost 75 characters
select a.location_code,
a.item_code,
b.description item_desc,
to_char(a.manufact_date,'ddMonyy')mfg,
to_char((a.manufact_date + nvl(b.expiry_period,0)),'ddMonyy')expr,
to_char((a.manufact_date + nvl(b.qurantine_period,0)),'ddMonyy')qrtn,
round(nvl (b.qurantine_period, 0) - (sysdate - a.manufact_date)) days_elapsed,
a.closing_balance_posted quantity
from wms_stock_current_balance_v a, wms_item_setup_mast b
where a.closing_balance > 0
and a.item_code = b.item_code
and a.loc_type in ('RACKING','PICKING','QUICKA','BUNDLED')
and nvl(b.qurantine_period,0) > 0
and round(nvl (b.qurantine_period, 0) - (sysdate - a.manufact_date)) <= 0
order by a.item_code, a.location_code;
Sample data of above query is
LOCATION_CODE
ITEM_CODE
ITEM_DESC
MFG
Expiry
Quarantine
Days Elapse
Quantity
13DL2
000000000000000F0487
CLEAR COOL BLACK 05ML
20-Feb-10
31-Mar-14
4-Jun-13
-122
160
14DL0
000000000000000F0487
CLEAR COOL BLACK 05ML
23-Feb-10
3-Apr-14
7-Jun-13
-119
134
14DL2
000000000000000F0487
CLEAR COOL BLACK 05ML
23-Feb-10
3-Apr-14
7-Jun-13
-119
160
14DR2
000000000000000F0487
CLEAR COOL BLACK 05ML
23-Feb-10
3-Apr-14
7-Jun-13
-119
20
14LL2
000000000000000F0487
CLEAR COOL BLACK 05ML
20-Feb-10
31-Mar-14
4-Jun-13
-122
160
17ER2
000000000000000F0487
CLEAR COOL BLACK 05ML
20-Feb-10
31-Mar-14
4-Jun-13
-122
160
17GL2
000000000000000F0487
CLEAR COOL BLACK 05ML
20-Feb-10
31-Mar-14
4-Jun-13
-122
160
17SL0
000000000000000F0487
CLEAR COOL BLACK 05ML
17-Feb-10
28-Mar-14
1-Jun-13
-125
64
18QL0
000000000000000F0487
CLEAR COOL BLACK 05ML
23-Feb-10
3-Apr-14
7-Jun-13
-119
160
19AR5
000000000000000F0487
CLEAR COOL BLACK 05ML
17-Feb-10
28-Mar-14
1-Jun-13
-125
160
19DL1
000000000000000F0487
CLEAR COOL BLACK 05ML
20-Feb-10
31-Mar-14
4-Jun-13
-122
160
19JR0
000000000000000F0487
CLEAR COOL BLACK 05ML
17-Feb-10
28-Mar-14
1-Jun-13
-125
60
19TL1
000000000000000F0487
CLEAR COOL BLACK 05ML
20-Feb-10
31-Mar-14
4-Jun-13
-122
160
20GR2
000000000000000F0487
CLEAR COOL BLACK 05ML
20-Feb-10
31-Mar-14
4-Jun-13
-122
40
36FL3
000000000000000F0487
CLEAR COOL BLACK 05ML
18-Feb-10
29-Mar-14
2-Jun-13
-124
65
19UR0
000000000000000F0591
COMFORT WHITE 24ML*300
28-Oct-09
28-Oct-11
1-May-11
-887
1
12SL1
000000000000000F0593
COMFORT PINK 24ML*300
28-Oct-09
28-Oct-11
1-May-11
-887
42
12SR1
000000000000000F0593
COMFORT PINK 24ML*300
28-Oct-09
28-Oct-11
1-May-11
-887
42
14OR1
000000000000000F0593
COMFORT PINK 24ML*300
28-Oct-09
28-Oct-11
1-May-11
-887
8
36EL4
000000000000000F0594
CLEAR HF DECRASE 5M*360
14-Feb-10
14-Feb-11
12-Oct-10
-1088
14
13VL1
000000000000000F0595
CLEAR COM SFT CRE 5*360
8-Feb-10
8-Feb-11
6-Oct-10
-1094
160
14ER0
000000000000000F0595
CLEAR COM SFT CRE 5*360
8-Feb-10
8-Feb-11
6-Oct-10
-1094
105
Database Info
Oracle 10g
Version 10.2.0.1.0Look at the sample code for generating a CSV file that I've just posted in response to a similar question:
Re: How to execute a proc and spool files in a database job
And the use the search button in this forum to find sample code for sending a CLOB as a plain/text e-mail attachment using UTL_SMTP. -
RFC fetching data from table which is not commited
Hi Experts,
I have a query regarding commit work.Below is the RFC that i have written
FUNCTION ZBAPI_CREATE.
*"*"Local Interface:
*" TABLES
*" IT_ZABAP_RFC STRUCTURE ZBAPI_RFC_STR OPTIONAL
*" RETURN STRUCTURE BAPIRET2 OPTIONAL
CALL FUNCTION 'ZBO_BAPI_CREATE'
TABLES
IT_ZABAP_RFC = IT_ZABAP_RFC
RETURN = return
Break-point.
DATA lt TYPE TABLE OF ZBAPI_RFC_STR_MAIN.
CALL FUNCTION 'ZBAPI_SEARCH_RANGE'
* EXPORTING
* IS_STR =
TABLES
ET_TAB = lt
* RETURN =
ENDFUNCTION.
here in first RFC call i am creating a record in ZTABLE , and then at break-point
i check the ZTABLE where it does not create any record because data is not commited into ZTABLE upto this point, but just after it i have written code for fetching data from ZTABLE but i am able to get this new record in lt.
Can anybody please explain that from where this serach RFC is providing data because inside serach i am simply selecting data from ZTABLE.
Regards,
Abhishek Bajpai
Edited by: ABHISHEK BAJPAI on Jan 28, 2009 1:12 PMHi Thomas,
Thanks for reply , i checked in ZTABLE ,before search RFC call data is not there but if i commit explicitly only then it is showing data in ZTABLE. Actually my requirement is different -
I have two RFCs 1. Create 2. Search , Now from web dynpro user will call first Create RFCs but at this point it should not insert record in ZTABLE and just after it user will call another search RFC and in this search he should be able to get these newly created records.
I want to have the functionality which a user gets when working with normal database front end like SQLPLus for Oracle. In these scenarios we see that whenever user does any insert or update the data sits in the table but still it is not committed. So there he fires Select query he sees the inserted data. But if he logs off from SQL PLUS and then logs in again, and fires Select query he does not see the data as it was not committed. I want a similiar functionalty in which if user inserts the data through Create RFC and fires the Select query through Search RFC then he can see the newly Created data also even though this data is not committed.
Although if i call create RFC in update task it will not update ZTABLE but in this situation , if user will call search RFC he will not be able to get newly created records.
So my requirement is that i should be able to get those records which are not commited in ZTABLE .If you have still any doubt regarding my question then please let me know.
Regards,
Abhishek -
Fetch data from table(ET_) which is exporting parameter of function module
Hi,
I m new to ABAP programming.
I have to develop a smartform that has to be filled in with fields from few tables.
These tables have the naming convention ET_<XXX> (i.e. exporting parameter of function module).
I m not able to directly view its contents in se11 or use select query for it.
I have a report program which i can execute to view these parameter names.
Now, how do i fetch data from these parameters/tables and pass it from my driver program to smartform??
Someone pls guide me...
Thank You.Hi,
I have done that using Field-Symbols.
Thanks,
Preetha -
Select query taking 30 sec to fetch data from table containing BLOB column.
Hi Friends,<o:p></o:p>
Please help me...<o:p></o:p>
I have 15 columns in a table, in that 2 columns containing blob (images).<o:p></o:p>
More than 22 lakhs records are in a table.<o:p></o:p>
While i am try to fetch data from this table it nearly takes 25~30 sec to execute that query.<o:p></o:p>
When i deleted the two columns containing blob and i tried its executing fast .<o:p></o:p>
I should not change the table schema.<o:p></o:p>
Views also i created and indexes also there in a table.<o:p></o:p>
How can i improve the query execution speed?.<o:p></o:p>And how large is the size of BLOB data in your table? If it's several giga bytes, then the time is simply required to read the amount of data from disk and to transfer it to the Client.
Olaf Helper
[ Blog] [ Xing] [ MVP] -
Hi all,
I am using function module through Call fucntion.
There i am getting <b>Table Name</b> as import Parameter.
Now i need to fetch data from that table (Which name we got througfh function module).
Is there any point to know how can we fetch data from runtime table .
i need some sample code for this.
Thanks inn advance,
Regards,
BhaskarHello Bhaskar,
I don't have an SCM system, so I cannot test out that FM
However, I modified the above code to update the table as well
*& Report ZKRIS_DYNAMIC_TABLE_READ_MOD
REPORT ZKRIS_DYNAMIC_TABLE_READ_MOD LINE-SIZE 256.
DATA : LV_FIELD_DESC TYPE STRING.
DATA : LV_DATA1 TYPE STRING.
DATA : LV_DETAIL(128).
DATA : COMMA TYPE C VALUE ','.
DATA : LV_TNAME LIKE DD02L-TABNAME.
DATA : LV_DBTAB1 LIKE DD02L-TABNAME.
DATA : DREF TYPE REF TO DATA.
DATA : FLAG_MODIFIED. " determines if database needs to be updated
FIELD-SYMBOLS: <ITAB> TYPE ANY TABLE, " used to store dynamic tables
<WA> TYPE ANY, " used to store record data
<WA1> TYPE ANY . " used to store field data
* call Fm /SAPAPO/TS_PA_COPY_TABLE_GET here
LV_DBTAB1 = 'ZGSTSET'. " <-- put your table name here
DATA: IT_FIELDS TYPE X031L OCCURS 0.
DATA: WA_FIELDS LIKE LINE OF IT_FIELDS.
CALL FUNCTION 'DDIF_NAMETAB_GET'
EXPORTING
tabname = LV_DBTAB1
* ALL_TYPES = ' '
* LFIELDNAME = ' '
* GROUP_NAMES = ' '
* UCLEN =
* IMPORTING
* X030L_WA =
* DTELINFO_WA =
* TTYPINFO_WA =
* DDOBJTYPE =
* DFIES_WA =
* LINES_DESCR =
TABLES
X031L_TAB = IT_FIELDS
* DFIES_TAB =
EXCEPTIONS
NOT_FOUND = 1
OTHERS = 2
IF sy-subrc <> 0.
* MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
* WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
* we do not know the sized of the table that must be generated beforehand
* hence we use field symbols to dynamically generate the internal table
CREATE DATA DREF TYPE STANDARD TABLE OF (LV_DBTAB1)
WITH NON-UNIQUE DEFAULT KEY.
ASSIGN DREF->* TO <ITAB> .
* selects all data
SELECT * FROM (LV_DBTAB1) INTO TABLE <ITAB> .
LOOP AT <ITAB> ASSIGNING <WA>.
FLAG_MODIFIED = ''.
LOOP AT IT_FIELDS INTO WA_FIELDS.
ASSIGN COMPONENT WA_FIELDS-FIELDNAME OF STRUCTURE <WA>
TO <WA1>.
IF WA_FIELDS-FIELDNAME = 'FIRSTNAME'. " fieldname in the table you wish to modify
IF <WA1> = 'Kris'. " old value
<WA1> = 'NewName'. " new value
MODIFY TABLE <ITAB> FROM <WA>.
FLAG_MODIFIED = 'X'.
ENDIF.
ENDIF.
WRITE <WA1>. " comment this line to remove the display
ENDLOOP.
IF FLAG_MODIFIED = 'X'. " updates database only if the record was changed
UPDATE (LV_DBTAB1) FROM <WA>.
* note that if the field you choose is a key field, sy-subrc will be set to 4
ENDIF.
* display
NEW-LINE.
ENDLOOP. -
Function module to fetch data from table SETLEAVES
Hi All,
We have a requirement to fetch the data from table SETLEAVES based on the setclass,subclass and group. As the table holds hierarchical data, Please let me know a FM which fetches all the hierarchical data from the table SETLEAVES.
Regards
ShivaTry:
exporting
e_class = '0102'
e_setid = setid
e_kokrs = my_kokrs
e_mandt = sy-mandt
e_master_data = 'XXX'
e_structure = 'X X0200'
e_replace_class = space
e_replace_unit = space
e_suffix = space
e_old_line_level = 1 "l_ol_level
tables
t_nodes = it_ceg_nodes
t_values = it_ceg_values
changing
c_info = c_info
c_overwrite = c_overwrite
exceptions
no_controlling_area = 1
no_chart_of_account = 2
different_controlling_areas = 3
different_chart_of_accounts = 4
set_not_found = 5
illegal_field_replacement = 6
illegal_table_replacement = 7
fm_raise = 8
convert_error = 9
no_overwrite_standard_hier = 10
no_bukrs_for_kokrs = 11
others = 12.
Rob -
Hi All,
I have to fetch data from t005u for the filed bezei.
based on conditions given below
1) pass kna1-land1 and kna1-regio to t005u-land1 and t005u-bland
and then i want to pass this to an alv filed.
thanks in advance
jayhi jay,
try this code.
select t005u~bezei
kna1~land1
kna1~regio
into table <itab>
from t005u join kna1
on t005u-land1 eq kna1-land1 and
t005u-bland eq kna1-regio
where <condition with selection-screen Parameters>
After fetching the data build the field catelog using <itab> and
pass it in the function module REUSE_ALV_GRID_DISPLAY.
<b><i>Reward points if useful</i></b>
Chandra
Message was edited by:
Chandrasekhar Velpula -
Sender JDBC.....pick data from table view?
Hi Experts,
working on JDBC for first time, so have few questions.
data base guys want to create a table view and we need to pick the data from table view.
my question is can we import the structure form data view?
if i am not able to import, so i need to create the structure same as in data base table view and is it case sensitive?
they dont want to update the data base table view, very time the SQL query will pick all the records form data base.
the records will be less then 10,000.
my question is as we are not updating the table view, what we need to write in update query as it is mandatory?
Regards,
ChinnaHello,
i hope below option help in update query
In place of the SQL statement, you can also enter <TEST>. Once the data determined from Query SQL Statement has been successfully sent, the data in the database remains unaltered.
This is recommended if the data has not only been read, but also changed by a stored procedure entered under Query SQL Statement. -
Please let me know how to write the Query to fetch data from tables
Hi Folks,
Please let me know how to get the data from different tables using the functionality SQ03,SQ02 and SQ01 .
Helpful answers will points awarded.
Regards,
Ram.Dear Ram,
Please find the below link which gives in detail with screen shots.
[SAP Query|http://media.techtarget.com/searchSAP/downloads/Teach_yourself_SAP_C20.pdf#search=%22CREATE%20REPORT%20USING%20SQVI%20%2C%20SAP%22]
Thanks
Murtuza -
Send mail with attachement in PDF Format
My Requriment is that After Executing the ALV report ....Oputput is too be Converting into the PDF Format and mail should goes to respective person.............So what is the Procedure for this .................
Regrads,
Sandeep JadhavHi Sandeep,
[Sending ALV Report as Email|"GLTRI--actual finish date" not getting populated;
Thanks & regards,
Dileep .C -
Function module to fetch data from table
Hi All,
I want to get the entries from the table 'arfcsstate' for a particular date. Is there a function module to get the same.
Thanks in advance.
Regards,
AnjuHi,
You can use select query
Select * from arfcsstate into <Internal table name>
where date <give ur condition.>
if date is in selection screen than write
date in s_date.
Thanx
Ankur Sharma -
Convert Screen(spool) to PDF file sending mail with attach file
Hi :
I'd like convert spool list to pdf and sending file...
so, I read thread about spool convert to PDF before,
and know how to convert Spool to PDF file and send mail with attach file.
but I have a problem.
my solution as:
step 1. Call function: "CONVERT_ABAPSPOOLJOB_2_PDF"
step 2. Call function: "SO_NEW_DOCUMENT_ATT_SEND_API1"
then, I got a mail with attached PDF file, but the PDF file display limited 255 line.( SO_NEW_DOCUMENT_ATT_SEND_API1 limited)
I want to showing word is wider that 255.
and then I find a manual method as:
After program finished.
Function Menu -> system -> List -> Send
use Prog: "Create Document and Send"
I use this prog sending mail and attached file ,
PDF file do <b>NOT</b> have 255 word limit !
finally. my question is, If I want sending mail as Prog: "Create Document and Send", how to do?
which Function I have to use?...
Please help me, Thanks!Hi,
Check this sample code of sending spool as attachment to an email address..
Parameters.
PARAMETERS: p_email(50) LOWER CASE.
PARAMETERS: p_spool LIKE tsp01-rqident.
Data declarations.
DATA: plist LIKE sopcklsti1 OCCURS 2 WITH HEADER LINE.
DATA: document_data LIKE sodocchgi1.
DATA: so_ali LIKE soli OCCURS 100 WITH HEADER LINE.
DATA: real_type LIKE soodk-objtp.
DATA: sp_lang LIKE tst01-dlang.
DATA: line_size TYPE i VALUE 255.
DATA: v_name LIKE soextreci1-receiver.
DATA rec_tab LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
Get the spool data.
CALL FUNCTION 'RSPO_RETURN_SPOOLJOB'
EXPORTING
rqident = p_spool
first_line = 1
last_line = 0
desired_type = ' '
IMPORTING
real_type = real_type
sp_lang = sp_lang
TABLES
buffer = so_ali
EXCEPTIONS
no_such_job = 1
job_contains_no_data = 2
selection_empty = 3
no_permission = 4
can_not_access = 5
read_error = 6
type_no_match = 7
OTHERS = 8.
IF sy-subrc <> 0.
MESSAGE s208(00) WITH 'Error'.
LEAVE LIST-PROCESSING.
ENDIF.
Prepare the data.
plist-transf_bin = 'X'.
plist-head_start = 0.
plist-head_num = 0.
plist-body_start = 0.
plist-body_num = 0.
plist-doc_type = 'RAW'.
plist-obj_descr = 'Test ALV'.
APPEND plist.
plist-transf_bin = 'X'.
plist-head_start = 0.
plist-head_num = 0.
plist-body_start = 1.
DESCRIBE TABLE so_ali LINES plist-body_num.
plist-doc_type = real_type.
Get the size.
READ TABLE so_ali INDEX plist-body_num.
plist-doc_size = ( plist-body_num - 1 ) * line_size
+ STRLEN( so_ali ).
APPEND plist.
Move the receiver address.
MOVE: p_email TO rec_tab-receiver,
'U' TO rec_tab-rec_type.
APPEND rec_tab.
IF NOT sp_lang IS INITIAL.
document_data-obj_langu = sp_lang.
ELSE.
document_data-obj_langu = sy-langu.
ENDIF.
v_name = sy-uname.
Send the email.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = document_data
sender_address = v_name
sender_address_type = 'B'
TABLES
packing_list = plist
contents_bin = so_ali
receivers = rec_tab
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 e208(00) WITH 'Error'.
ENDIF.
COMMIT WORK.
Send the email immediately.
SUBMIT rsconn01
WITH mode = 'INT'
AND RETURN.
Thanks,
Naren -
Send mail with attachment from the uploaded file
hi,
From a form thread i got the following code to send mail with attachment with the file uploaded from the file upload ui element.
public void onActionLoadFile(com.sap.tc.webdynpro.progmodel.api.IWDCustomEvent wdEvent )
//@@begin onActionLoadFile(ServerEvent)
WDWebResourceType FileType = null;
String FileName = new String();
//get attribute info for context attribute 'FileUpload'
IWDAttributeInfo attributeInfo =
wdContext.getNodeInfo().getAttribute(
IPrivateEmailView.IContextElement.FILE_UPLOAD);
//get modifiable binary type from the attribute info,requires type cast.
IWDModifiableBinaryType binaryType =
(IWDModifiableBinaryType) attributeInfo.getModifiableSimpleType();
IPrivateEmailView.IContextElement element =
wdContext.currentContextElement();
//if a file in the 'FileResource' attribute exists
if (element.getFileUpload() != null) {
try {
String mimeType = binaryType.getMimeType().toString();
byte[] file = element.getFileUpload();
//get the size of the uploaded file
element.setFileSize(this.getFileSize(file));
//get the extension of the uploaded file
element.setFileExtension(binaryType.getMimeType().getFileExtension());
//NOTE: context attribute 'FileName' must not be set
//because the FileUpload-UI-element property 'fileName'
//is bound to it. Consequently the fileName is automatically
//written to the context after file upload.
//report success message
wdComponentAPI.getMessageManager().reportMessage(
IMessageEmailComp.SF_UPLOAD,
new Object[] { binaryType.getFileName()},
false);
FileType = binaryType.getMimeType();
FileName = binaryType.getFileName();
} catch (Exception e) {
throw new WDRuntimeException(e);
//if no file in the 'FileResource' attribute exists
else {
//report error message
IWDMessageManager msgMgr = wdComponentAPI.getMessageManager();
msgMgr.reportContextAttributeMessage(
element,
attributeInfo,
IMessageEmailComp.NO_FILE,
new Object[] { "" },
true);
//clear the FileResource context value attribute
//element.setFileUpload(null);
String URL;
URL = this.CreateAndGetPathFileUpload(
wdContext.currentContextElement().getFileUpload(),
FileName);
// if (URL.length() == 1){
// //ERRORE
wdContext.currentContextElement().setPATHFileUploaded(URL);
//@@end
public boolean send( java.lang.String subj, java.lang.String mess, java.lang.String dest, java.lang.String attach, java.lang.String FileName )
//@@begin send()
InitialContext ctx = null;
Address[] address = null;
Message msg = null;
Session sess = null;
MimeBodyPart bodyPart = null;
Multipart mp = null;
// "141.29.193.71" == milvl2ja.icn.siemens.it (SMTP di Siemens)
try {
Properties props = new Properties();
props.put("domain","true");
ctx = new InitialContext(props);
sess = (Session) ctx.lookup("java:comp/env/mail/MailSession");
msg = new MimeMessage(sess);
IWDClientUser utente = WDClientUser.getCurrentUser();
String senderEmail = utente.getSAPUser().getEmail();
InternetAddress addressFrom = new InternetAddress(senderEmail);
msg.setFrom(addressFrom);
String EmailDEST = dest;
InternetAddress addressTo = new InternetAddress(EmailDEST);
msg.setRecipient(Message.RecipientType.TO, addressTo);
msg.setSubject(subj);
// if ((mess != null) && (mess.length()>0)) {
// msg.setContent(mess, "text/plain");
// } else {
// msg.setContent("", "text/plain");
//Gestione ATTACHMENT...
String attachedFileName = new String(wdContext.currentContextElement().getFileName());
boolean hasAttachment = (attachedFileName != null) && (attachedFileName.length() > 0);
boolean isMultiPart = (mess != null) && (mess.length() > 1);
//adding an attachment makes the message multipart
if (isMultiPart || hasAttachment) {
mp = new MimeMultipart();
// add text parts
if (mess != null) {
for (int i = 0; i < mess.length(); i++) {
bodyPart = new MimeBodyPart();
bodyPart.setContent(mess,"text/plain");
mp.addBodyPart(bodyPart);
//attach the file to the message if needed
if (hasAttachment) { // avoid the case with no text parts
bodyPart = new MimeBodyPart();
bodyPart.setContent("Allegato incluso nel messaggio.","text/plain");
mp.addBodyPart(bodyPart);
// the part with the file
FileDataSource fds = new FileDataSource(attach);
MimeBodyPart attachmentBodyPart = new MimeBodyPart();
attachmentBodyPart.setDataHandler(new DataHandler(fds));
//URL URLattachedFileName = new URL(attach);
//attachmentBodyPart.setDataHandler(new DataHandler(URLattachedFileName));
attachmentBodyPart.setFileName(FileName);
mp.addBodyPart(attachmentBodyPart);
msg.setContent(mp);
} else {
if ((mess != null) && (mess.length() > 0)) {
msg.setContent(mess, "text/plain");
} else {
msg.setContent("", "text/plain");
//fine ATTACHMENT
msg.setSentDate(new GregorianCalendar().getTime());
msg.saveChanges();
address = msg.getAllRecipients();
Transport.send(msg, address);
} catch (Exception e) {
e.printStackTrace();
return false;
return true;
//@@end
When i used the same code in my application i am gett ing error in many places..
1)FileDataSource fds = new FileDataSource(<b>attach</b>);
attach cannot be resolved
2)attachmentBodyPart.setFileName(<b>FileName</b>);
fliename cannot be resolved
3)byte[] file = element.getFileUpload();
type mismatch cannot convert sting to byte[]
4)element.setFileSize(this.getFileSize(file));
method getFileSize() is undefined
5)element.setFileExtension(binaryType.getMimeType().getFileExtension());
method getFilExtension() is undefined
6)URL = this.CreateAndGetPathFileUpload(wdContext.currentContextElement().getFileUpload(),FileName);
method CreateAndGetPathFileUpload() is undefined.
7)wdContext.currentContextElement().setPATHFileUploaded(URL);
from the above error i can understand that only i have got the part of the code.
Please send me the complete coding.
some method definitions are missing....
Please help me to send the mail with attachment from the file uploaded from the file upload ui element.
Thanks in advance,
shami.hi,
I got this from the following link
Re: Attaching an excel file
plz help me ...
I am using 2004s with nwds 7.0.06.
also tell me what should be the type of the context variable FileUpload
Thanks in advance,
shami. -
Convert Script output data to Text(.txt) file & send mail with attachment.
Hi All,
Requirement: I shulb be able to conver th Script output data to Text(.text) file & send a maill with attachment with this text file. Formant of text file should be like output of Print priview.
Plese sugget with Function modules to cover as Text file.
I am able to converting the Script output data to PDF and sending mail with attachment. So I don't want PDF file now.
Thanks in advance.Hi, Thanks for responst.
We can convert the Scirpt output to PDF file by using OTF function module and the PDF file looks like Print Privew output.
Same like this I want Script out in NOTEPAD (.txt). Is that possible, Plz sugget with relavent Function Modules.
Thanks.
Maybe you are looking for
-
Error Message in EoL/EoS Report
currently running LMS 3.2 get the following error message when running the Eol/Eos report: under reason for failure get unable to get data from Cisco.com try again later. using the same login that is used to login to Cisco.com.
-
Updating to ios 6.1.2 on my ipad stuck
Updating to ios 6.1.2 on my ipad (3rd gen) and it now seems stuck at just over 50% and has been that way for at least an hour. Any ideas?
-
A way to color the clips on the timeline?
Hi guys, so now I would like to know of a way to color the clips on the time line.. or set up markers somehow so I know which parts of the time line I need to have my attention on later. Thanks!
-
Oracle Apllication Server 10.1.3.1
Please all i am new to OAS and I need the link from oracle where i can i download the oracle application server 10.1.3.1 for oracle linux 64, any suggestion please i am not being able to find this release. Your assistance is highly appreciated Regard
-
IPhone Not Detected in itunes on windows
Right, My iphone works fine on mac no problems but when I try to run it on windows using parallels it doesn't work. It will not show up in itunes at all (on windows). I am sure there is some kind of nube fix for this. It does show as being connected