Send text file as an attachment
Hi All,
We have a requirement wherein we need to send the contents of an
internal table in a text pipe delimited file as an attachment in to an
external mail id.
The problem is that the total record length of the internal table is
around 450 char while the structure SOLI accepts only 255 char.
This causes the record to be split into 2 lines.
Is it possible to send the entire 450 char in one line? If yes, how can
this be done?
Thanks,
fractal
I think u shd use this FM for line width change:-
CALL FUNCTION 'SX_TABLE_LINE_WIDTH_CHANGE'
EXPORTING
LINE_WIDTH_SRC = 134 "ur source width
LINE_WIDTH_DST = 255
TRANSFER_BIN = ' '
TABLES
CONTENT_IN = GT_PDF "ur itab name
CONTENT_OUT = LT_ATT
EXCEPTIONS
ERR_LINE_WIDTH_SRC_TOO_LONG = 1
ERR_LINE_WIDTH_DST_TOO_LONG = 2
ERR_CONV_FAILED = 3
OTHERS = 4
Similar Messages
-
SENDING TEXT FILE AS AN ATTACHMENT
Hi,
I want to send an email as a TEXT file attachment.
Thanks
Vikranth Khimavathhi,
Use the FM SO_NEW_DOCUMENT_ATT_SEND_API1 to send mail with an attachment. Here is the sample code.
FUNCTION Z_SEND_MAIL.
""Local interface:
*" IMPORTING
*" VALUE(MESSAGE) TYPE STRING OPTIONAL
*" VALUE(RECEIVER_MAIL) TYPE STRING OPTIONAL
*" VALUE(TO) TYPE STRING OPTIONAL
data for send function
DATA doc_data TYPE sodocchgi1.
DATA object_id TYPE soodk.
DATA objcont TYPE TABLE OF soli INITIAL SIZE 10.
DATA wa_objcont LIKE LINE OF objcont.
DATA receiver TYPE TABLE OF somlreci1 INITIAL SIZE 1.
DATA wa_receiver LIKE LINE OF receiver.
move message
TO doc_data-obj_descr .
This is the subject for your mail.
WRITE 'Sub:test Mail' TO doc_data-obj_descr.
This is the body of your mail.
concatenate ' Hi ' to into wa_objcont-line separated by space.
append wa_objcont to objcont.
wa_objcont-line = message.
append wa_objcont to objcont.
Specify receipent id.
MOVE: RECEIVER_MAIL TO wa_receiver-receiver,
'X' TO wa_receiver-express,
'U' TO wa_receiver-rec_type.
APPEND wa_receiver TO receiver.
Finally call the function module.
CALL FUNCTION 'SO_NEW_DOCUMENT_SEND_API1'
EXPORTING
document_data = doc_data
put_in_outbox = 'X' "Save Document in Outbox
COMMIT_WORK = 'X'
IMPORTING
new_object_id = object_id
TABLES
object_content = objcont
receivers = receiver
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.
SUBMIT rsconn01 USING SELECTION-SET 'SAP&CONNECTINT' AND RETURN.
ENDFUNCTION.
REPORT RSCONN01 MESSAGE-ID XS NO STANDARD PAGE HEADING.
INCLUDE <SYMBOL>. " 11.11.96
TYPE-POOLS: SX.
TYPE-POOLS: KKBLO.
PARAMETERS: MODE(3) TYPE C DEFAULT '*',
OUTPUT TYPE C DEFAULT ' '. "B20K072036 new parameter
selection-screen skip.
parameters maxjobs type sx_maxjobs default 1.
parameters rfcgroup type bdfields-rfcgr.
selection-screen skip.
parameters maxpsize type sx_maxpsize default 1000.
parameters minpsize type sx_minpsize default 20.
parameters maxsel type sx_maxqrows default 20000.
parameters timepo type sx_timepo default 2.
parameters timeout type sx_arfctimeout default 100.
parameters commit type sx_commit default 1.
data address_types type sx_addrtab.
data job_params type sxjobs.
data jobdata type sxjobdata.
--- initialization -
initialization.
get default parameters
call function 'SX_JOBDATA_GET'
changing
jobdata = jobdata.
give defaults to parameters
maxjobs = jobdata-maxjobs.
maxpsize = jobdata-maxpsize.
minpsize = jobdata-minpsize.
maxsel = jobdata-maxsel.
timepo = jobdata-timepo.
timeout = jobdata-arfc_timeout.
commit = jobdata-commit_after.
--- start-of-selection -
start-of-selection.
perform addr_type_to_table using mode
changing address_types.
job_params-maxjobs = maxjobs.
job_params-rfcgroup = rfcgroup.
job_params-maxpsize = maxpsize.
job_params-minpsize = minpsize.
job_params-maxsel = maxsel.
job_params-timepo = timepo.
job_params-arfc_timeout = timeout.
job_params-commit_after = commit.
call function 'SX_OBJECTS_SEND'
exporting
address_types = address_types
output = output
job_params = job_params
exceptions
others = 1.
if sy-subrc <> 0.
message id sy-msgid type sy-msgty number sy-msgno
with sy-msgv1 sy-msgv2 sy-msgv3 sy-msgv4.
endif.
exit.
TABLES: SXADDRTYPE.
DATA: selection type SX_ADDRTAB,
NR_SO_OBJECTS TYPE I,
OBJ_CAT TYPE SX_OBJ_CAT OCCURS 20 WITH HEADER LINE.
if sy-batch = 'X'.
message I078 with 'RSCONN01' SY-HOST SY-MANDT.
endif.
*fill selection table
refresh selection.
if mode = '*'.
clear mode.
endif.
IF NOT ( MODE IS INITIAL ).
SELECT SINGLE * FROM SXADDRTYPE WHERE ADDR_TYPE EQ MODE.
IF SY-SUBRC NE 0.
IF OUTPUT EQ 'X'.
WRITE: MODE, TEXT-001, TEXT-002.
ENDIF.
EXIT.
ENDIF.
IF SXADDRTYPE-METHOD NE 'SAPCONNECT'.
IF OUTPUT EQ 'X'.
WRITE: MODE, TEXT-003, TEXT-004, TEXT-005.
ENDIF.
EXIT.
ENDIF.
append sxaddrtype-addr_type to selection.
ELSE.
select * from sxaddrtype
where method = 'SAPCONNECT'
and extern = sx_true.
case sxaddrtype-addr_type.
when 'INT' or 'FAX' or 'PAG' or
'PRT' or 'RML' or 'X40'.
append sxaddrtype-addr_type to selection.
endcase.
endselect.
ENDIF.
CALL FUNCTION 'SX_OBJECTS_SEND'
EXPORTING
ADDRESS_TYPES = SELECTION
IMPORTING
NR_SO_OBJECTS = NR_SO_OBJECTS
TABLES
OBJ_CAT = OBJ_CAT
EXCEPTIONS
INTERNAL_ERROR = 1
OTHERS = 2.
IF SY-SUBRC NE 0.
IF OUTPUT EQ 'X'.
Always write out this error message:
WRITE: TEXT-006, SY-SUBRC.
ENDIF.
EXIT.
ENDIF.
IF NR_SO_OBJECTS = 0.
IF OUTPUT EQ 'X'.
WRITE: TEXT-007.
ENDIF.
EXIT.
ENDIF.
IF OUTPUT EQ 'X'.
PERFORM DISPLAY_OBJECT_CATALOGUE.
ENDIF.
AT SELECTION-SCREEN ON VALUE-REQUEST FOR MODE.
PERFORM F_SHOW_ADDR_TYPES CHANGING MODE.
AT SELECTION-SCREEN ON HELP-REQUEST FOR OUTPUT.
PERFORM F_HELP_OUTPUT.
*& Form addr_type_to_table
text
form addr_type_to_table using address_type type sx_addrtyp
changing address_types type sx_addrtab.
data adrtp_wa type sxaddrtype.
data adrtp type sx_addrtyp.
if address_type <> '*'.
adrtp = address_type.
endif.
if not adrtp is initial.
select single * from sxaddrtype into adrtp_wa
where addr_type = adrtp.
if sy-subrc <> 0.
message i009 with adrtp.
exit.
endif.
if adrtp_wa-method ne 'SAPCONNECT'.
message i027 with adrtp.
exit.
endif.
append adrtp_wa-addr_type to address_types.
else.
select * from sxaddrtype into adrtp_wa
where method = 'SAPCONNECT'
and extern = sx_true.
case adrtp_wa-addr_type.
when 'INT' or 'FAX' or 'PAG' or
'PRT' or 'RML' or 'X40'.
append adrtp_wa-addr_type to address_types.
endcase.
endselect.
endif.
endform. " addr_type_to_table
*& Form DISPLAY_OBJECT_CATALOGUE
Anzeige der Liste der zum Versenden selektierten Objekte
--> p1 text
<-- p2 text
FORM DISPLAY_OBJECT_CATALOGUE.
DATA: FIELD_LST TYPE KKBLO_T_FIELDCAT.
DATA: FIELD_CAT TYPE KKBLO_FIELDCAT.
DATA: IS_LAYOUT TYPE KKBLO_LAYOUT.
IS_LAYOUT-NO_ZEBRA = 'X'.
FIELD_CAT-REF_TABNAME = 'SXOBJCAT'.
FIELD_CAT-NO_SUM = 'X'.
FIELD_CAT-JUST = 'L'.
FIELD_CAT-OUTPUTLEN = 3.
FIELD_CAT-REPTEXT = 'Trc'.
FIELD_CAT-FIELDNAME = 'DISPL_TRC'.
FIELD_CAT-HOTSPOT = 'X'.
FIELD_CAT-SYMBOL = 'X'.
APPEND FIELD_CAT TO FIELD_LST.
FIELD_CAT-SYMBOL = ' '.
FIELD_CAT-OUTPUTLEN = 0.
FIELD_CAT-HOTSPOT = ' '.
FIELD_CAT-REPTEXT = ' '.
CLEAR: FIELD_CAT-NO_ZERO, FIELD_CAT-KEY .
FIELD_CAT-FIELDNAME = 'ID'. APPEND FIELD_CAT TO FIELD_LST.
FIELD_CAT-FIELDNAME = 'TITLE'. APPEND FIELD_CAT TO FIELD_LST.
FIELD_CAT-FIELDNAME = 'TYPE'. APPEND FIELD_CAT TO FIELD_LST.
FIELD_CAT-FIELDNAME = 'NR_RECIP'. APPEND FIELD_CAT TO FIELD_LST.
LOOP AT FIELD_LST INTO FIELD_CAT.
FIELD_CAT-COL_POS = SY-TABIX.
MODIFY FIELD_LST FROM FIELD_CAT.
ENDLOOP.
LOOP AT OBJ_CAT.
OBJ_CAT-DISPL_TRC = SYM_PENCIL.
MODIFY OBJ_CAT.
ENDLOOP.
CALL FUNCTION 'K_KKB_LIST_DISPLAY'
EXPORTING
I_CALLBACK_PROGRAM = 'RSCONN01'
I_CALLBACK_USER_COMMAND = 'CB_OL_UCOMM'
I_CALLBACK_TOP_OF_PAGE = 'CB_OL_TOP'
I_CALLBACK_PF_STATUS_SET = 'CB_OL_PFSTATUS'
I_TABNAME = 'OBJ_CAT'
IS_LAYOUT = IS_LAYOUT
IT_FIELDCAT = FIELD_LST
TABLES
T_OUTTAB = OBJ_CAT
EXCEPTIONS
OTHERS = 1.
ENDFORM. " DISPLAY_OBJECT_CATALOGUE
*& Form CB_OL_PFSTATUS
Callback Funktion (wird aus Listtool heraus gerufen) *
--> p1 text
<-- p2 text
FORM CB_OL_PFSTATUS
USING EXTAB TYPE KKBLO_T_EXTAB.
SET PF-STATUS 'CATALOG' EXCLUDING EXTAB.
SET TITLEBAR 'CAT'.
ENDFORM. " CB_OL_PFSTATUS
*& Form CB_OL_TOP
Callback Funktion (wird aus Listtool heraus gerufen) *
--> p1 text
<-- p2 text
FORM CB_OL_TOP.
ENDFORM. " CB_OL_TOP
*& Form CB_OL_UCOMM
text *
--> p1 text
<-- p2 text
FORM CB_OL_UCOMM
USING UCOMM LIKE SY-UCOMM
SELFIELD TYPE KKBLO_SELFIELD.
DATA: NUMC5(5) TYPE N.
NUMC5 = SELFIELD-TABINDEX.
CASE UCOMM.
WHEN 'PIC1'.
CASE SELFIELD-SEL_TAB_FIELD.
WHEN 'OBJ_CAT-DISPL_TRC' OR 'OBJ_CAT-TITLE' OR 'OBJ_CAT-ID'.
READ TABLE OBJ_CAT INDEX SELFIELD-TABINDEX.
IF SY-SUBRC NE 0.
MESSAGE E042.
ENDIF.
SUBMIT RSWTTR01
WITH P_TYPE = 'D'
WITH P_UNAME = SPACE
WITH P_OBJ = OBJ_CAT-ID AND RETURN.
WHEN OTHERS.
MESSAGE I041 WITH NUMC5 SELFIELD-SEL_TAB_FIELD UCOMM.
ENDCASE.
WHEN OTHERS.
MESSAGE I041 WITH NUMC5 SELFIELD-SEL_TAB_FIELD UCOMM.
ENDCASE.
ENDFORM. " CB_OL_UCOMM
*& Form F_SHOW_ADDR_TYPES
text
<--P_MODE text *
FORM F_SHOW_ADDR_TYPES CHANGING A_TYPE.
DATA: HELP_INFO LIKE HELP_INFO
, sel_value like help_info-fldvalue
, CUCOL LIKE SY-CUCOL
, CUROW LIKE SY-CUROW
, value like help_info-fldvalue value 'SE38'
, IND LIKE SY-INDEX
, C_SY_SUBRC(3) TYPE C
DATA: BEGIN OF FIELDS OCCURS 5.
INCLUDE STRUCTURE HELP_VALUE.
DATA: END OF FIELDS.
DATA: BEGIN OF LIST_OF_FIELDS OCCURS 5,
NAME(21) TYPE C.
DATA: END OF LIST_OF_FIELDS.
DATA: BEGIN OF FULL_LIST OCCURS 5,
ADDRESS_TYPE LIKE SXADDRTYPE-ADDR_TYPE,
END OF FULL_LIST.
REFRESH FIELDS.
REFRESH LIST_OF_FIELDS.
REFRESH FULL_LIST.
HELP_INFO-TABNAME = 'SXADDRTYPE'.
HELP_INFO-FIELDNAME = 'ADDR_TYPE'.
SELECT * FROM SXADDRTYPE.
IF SXADDRTYPE-METHOD NE 'SAPCONNECT'
OR SXADDRTYPE-EXTERN NE SX_TRUE.
CONTINUE.
ENDIF.
MOVE SXADDRTYPE-ADDR_TYPE TO FULL_LIST-ADDRESS_TYPE.
APPEND FULL_LIST.
ENDSELECT.
MOVE '*' TO FULL_LIST-ADDRESS_TYPE.
APPEND FULL_LIST.
LIST_OF_FIELDS-NAME = 'SXADDRTYPE-ADDR_TYPE'.
APPEND LIST_OF_FIELDS.
CALL FUNCTION 'TRANSFER_NAMES_TO_FIELDS'
EXPORTING
SELECTFIELD = HELP_INFO-FIELDNAME
TABLES
FIELDS = FIELDS
NAMELIST = LIST_OF_FIELDS
EXCEPTIONS
WRONG_FORMAT_GIVEN = 1
OTHERS = 2.
CALL FUNCTION 'HELP_VALUES_GET_WITH_VALUE'
EXPORTING
DISPLAY = ' '
FIELDNAME = HELP_INFO-FIELDNAME
TABNAME = HELP_INFO-TABNAME
GIVEN_VALUE = HELP_INFO-FLDVALUE
TITEL = TEXT-002
IMPORTING
SELECT_VALUE = HELP_INFO-FLDVALUE
SELECT_INDEX = IND
TABLES
FIELDS = FIELDS
VALUETAB = FULL_LIST
EXCEPTIONS
FIELD_NOT_IN_DDIC = 1
MORE_THEN_ONE_SELECTFIELD = 2
NO_SELECTFIELD = 3
OTHERS = 4.
C_SY_SUBRC = SY-SUBRC.
CASE SY-SUBRC.
WHEN '0'.
READ TABLE FULL_LIST INTO A_TYPE INDEX IND.
WHEN OTHERS.
MESSAGE E022 WITH C_SY_SUBRC.
ENDCASE.
ENDFORM. " F_SHOW_ADDR_TYPES
*& Form F_HELP_OUTPUT
text
--> p1 text
<-- p2 text
FORM F_HELP_OUTPUT.
DATA: CANCELLED TYPE C,
C_SY_SUBRC(8) TYPE C.
CALL FUNCTION 'POPUP_DISPLAY_TEXT'
EXPORTING
LANGUAGE = SY-LANGU
POPUP_TITLE = 'SAPconnect'
TEXT_OBJECT = 'RSCONN01_F1_OUTPUT_40B'
IMPORTING
CANCELLED = CANCELLED
EXCEPTIONS
TEXT_NOT_FOUND = 1
OTHERS = 2.
C_SY_SUBRC = SY-SUBRC.
IF SY-SUBRC NE 0.
MESSAGE E035 WITH C_SY_SUBRC. leads to dump !
ENDIF.
ENDFORM. " F_HELP_OUTPUT
Regards,
Richa -
How to send text file as an attachment to exteral mail
hi ,
Can any one tell me how to send an internal table as a textfile attachment to the external mail.
regards
kishorehi,
i am assuming txt fie attachment means you want notepad attachment
recently i struggled on this and i achieved success by doing as below
remember to keep packlist as RAW type like below:
t_packing_list-doc_type = 'RAW'.
do like this
CALL FUNCTION 'SO_SOLITAB_TO_SOLIXTAB'
EXPORTING
ip_solitab = t_attachment[]
IMPORTING
EP_SOLIXTAB = xtext[].
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = w_doc_data
PUT_IN_OUTBOX = 'X'
COMMIT_WORK = 'X'
tables
packing_list = t_packing_list
OBJECT_HEADER =
CONTENTS_BIN = objbin
CONTENTS_TXT = it_message
CONTENTS_HEX = xtext
OBJECT_PARA =
OBJECT_PARB =
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 -
How to attach a text file as an attachment to email message?
Hello Everybody,
I have a .csv file, in which details about emp-id, emp-name, e-expenses for Reimbursement and email address are stored.
My application reads this .csv file, and sends a mail to each employee with his id, salary details in text format. (by changing content type to "text/plain") The code is working fine. But,
My problem is:
The message is sent as message body to the end user.
The end user / the person who receives this mail will not be a technical person. So,
1) If he trys to take a print out of this e-mail, He get only half of it.(as no. of colums will be more than paper size).
2) I am finding alignment problem. IF employee name is too big, other columns will shift to right and data will not be exactly under column header. (it is going in zig zag way)
So, I thought sending text file with all the details as an attachment might do well.
But, I don't know how to attach a text file to email-message body.
code
try
{ String s1="";
File f1 = new File(the path);
FileInputStream fstream = new FileInputStream(f1); //new
BufferedReader br = new BufferedReader(new InputStreamReader(fstream));
int count=0;
while((s1=br.readLine())!=null )
count++;
//out.println("within while loop "+count);
StringTokenizer st = new StringTokenizer(s1,",");
if ((st.hasMoreTokens())&&(count>1))
String a=st.nextToken().trim();
String b=st.nextToken();
String c=st.nextToken();
String d=st.nextToken();
String e=st.nextToken();
String f=st.nextToken();
String g=st.nextToken();
String h=st.nextToken();
String i=st.nextToken();
String j=st.nextToken();
String k=st.nextToken();
String l=st.nextToken();
String m=st.nextToken();
String n=st.nextToken();
String o=st.nextToken();
String p=st.nextToken();
String q=st.nextToken();
String mail=st.nextToken();
String s=st.nextToken();
//out.println("b="+b+"c="+c+"d="+d+"e="+e+"f="+f+"mail="+mail);
%>
<%
String to =mail;
String from =request.getParameter("fromadd");
String subject ="Statement of Expenses";
String smtp ="mail.xxxxxxxxxx.com";
String message="";
message=message.concat("EMP ID");
message=message.concat(" ");
message=message.concat("Name");
message=message.concat(" ");
message=message.concat("Dept No.");
message=message.concat(" ");
message=message.concat("Acc No.");
message=message.concat(" ");
message=message.concat("*****************************************************************************************");
message=message.concat(a);
message=message.concat(" ");
message=message.concat(b);
message=message.concat(" ");
message=message.concat(c);
message=message.concat(" ");
message=message.concat(d);
Properties props = System.getProperties();
// Puts the SMTP server name to properties object
props.put("mail.smtp.host", smtp);
// Get the default Session using Properties Object
Session session1 = Session.getDefaultInstance(props, null);
// Create a New message
MimeMessage msg = new MimeMessage(session1);
// Set the From address
msg.setFrom(new InternetAddress(from));
// Setting the "To recipients" addresses
msg.setRecipients(Message.RecipientType.TO,InternetAddress.parse(to, false));
/* // Setting the "cc recipients" addresses
msg.setRecipients(Message.RecipientType.CC,InternetAddress.parse(cc, false));
// Setting the "Bcc recipients" addresses
msg.setRecipients(Message.RecipientType.BCC,InternetAddress.parse(bcc, false)); */
// Sets the Subject
msg.setSubject(subject);
// set the meaasge in HTML format
msg.setContent(message,"text/plain");
// Set the Date: header
msg.setSentDate(new java.util.Date());
// Send the message
Transport.send(msg);
// Display Success message
result =result.concat("<tr><td>"+b+"</td>"+"<td>"+to+"</td></tr>");
}//end of if of hasmore element
}// end of while loop
out.println(result);
}catch(Exception e)
// If here, then error in sending Mail. Display Error message.
result="Unable to send your message";
out.println("e="+e);
Any help will be appreciated.
Thanks and regards.
Ashvini<html>
<p>
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText("Your Messages");
MimeBodyPart mbp2 = new MimeBodyPart();
FileDataSource fds = new FileDataSource("Your Attachments");
mbp2.setDataHandler(new DataHandler(fds));
mbp2.setFileName(fds.getName());
Multipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);
msg.setContent(mp);
msg.saveChanges();
msg.writeTo(System.out);
msg.setSubject(subject);
Transport.send(msg);
</p>
<B><U>See you can add above code in your program and see the magic</U></B>
Bye
regards--
Ashish
</html> -
Sending text files as attachments in mails
Hi Experts,
I want to send some content in a text file as an attachment in the mail. Can anybody provide me the sample code for this.
points guaranteed.
thanks
sanakrHI
Check this one
first create a Include report with the following coding
*& Include ZPA1_INCLFOR_MAIL *
* Data
DATA: docdata LIKE sodocchgi1,
objpack LIKE sopcklsti1 OCCURS 1 WITH HEADER LINE,
objhead LIKE solisti1 OCCURS 1 WITH HEADER LINE,
objtxt LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objbin LIKE solisti1 OCCURS 10 WITH HEADER LINE,
objhex LIKE solix OCCURS 10 WITH HEADER LINE,
reclist LIKE somlreci1 OCCURS 1 WITH HEADER LINE.
DATA: tab_lines TYPE i,
doc_size TYPE i,
att_type LIKE soodk-objtp.
DATA: listobject LIKE abaplist OCCURS 1 WITH HEADER LINE.
* FORM
FORM ml_customize USING objname objdesc.
*----------- Clear Variables
CLEAR docdata.
REFRESH objpack.
CLEAR objpack.
REFRESH objhead.
REFRESH objtxt.
CLEAR objtxt.
REFRESH objbin.
CLEAR objbin.
REFRESH objhex.
CLEAR objhex.
REFRESH reclist.
CLEAR reclist.
REFRESH listobject.
CLEAR listobject.
CLEAR tab_lines.
CLEAR doc_size.
CLEAR att_type.
*--------- Set Variables
docdata-obj_name = objname.
docdata-obj_descr = objdesc.
ENDFORM. "ml_customize
* FORM
FORM ml_addrecp USING preceiver prec_type.
CLEAR reclist.
reclist-receiver = preceiver.
reclist-rec_type = prec_type.
APPEND reclist.
ENDFORM. "ml_customize
* FORM
FORM ml_addtxt USING ptxt.
CLEAR objtxt.
objtxt = ptxt.
APPEND objtxt.
ENDFORM. "ml_customize
* FORM
FORM ml_prepare USING bypassmemory whatatt_type whatname.
IF bypassmemory = ''.
*--------- Fetch List From Memory
CALL FUNCTION 'LIST_FROM_MEMORY'
TABLES
listobject = listobject
EXCEPTIONS
OTHERS = 1.
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'LIST_FROM_MEMORY'.
ENDIF.
CALL FUNCTION 'TABLE_COMPRESS'
* IMPORTING
* COMPRESSED_SIZE =
TABLES
in = listobject
out = objbin
EXCEPTIONS
OTHERS = 1
IF sy-subrc <> 0.
MESSAGE ID '61' TYPE 'E' NUMBER '731'
WITH 'TABLE_COMPRESS'.
ENDIF.
ENDIF.
* Header Data
* Already Done Thru FM
* Main Text
* Already Done Thru FM
* Packing Info For Text Data
DESCRIBE TABLE objtxt LINES tab_lines.
READ TABLE objtxt INDEX tab_lines.
docdata-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objtxt ).
CLEAR objpack-transf_bin.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = 'TXT'.
APPEND objpack.
* Packing Info Attachment
att_type = whatatt_type..
DESCRIBE TABLE objbin LINES tab_lines.
READ TABLE objbin INDEX tab_lines.
objpack-doc_size = ( tab_lines - 1 ) * 255 + STRLEN( objbin ).
objpack-transf_bin = 'X'.
objpack-head_start = 1.
objpack-head_num = 0.
objpack-body_start = 1.
objpack-body_num = tab_lines.
objpack-doc_type = att_type.
objpack-obj_name = 'ATTACHMENT'.
objpack-obj_descr = whatname.
APPEND objpack.
* Receiver List
* Already done thru fm
ENDFORM. "ml_prepare
* FORM
FORM ml_dosend.
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = docdata
put_in_outbox = 'X'
commit_work = 'X' "used from rel. 6.10
* IMPORTING
* SENT_TO_ALL =
* NEW_OBJECT_ID =
TABLES
packing_list = objpack
object_header = objhead
contents_bin = objbin
contents_txt = objtxt
* CONTENTS_HEX = objhex
* OBJECT_PARA =
* object_parb =
receivers = reclist
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 'SO' TYPE 'S' NUMBER '023'
WITH docdata-obj_name.
ENDIF.
ENDFORM. "ml_customize
* FORM
FORM ml_spooltopdf USING whatspoolid.
DATA : pdf LIKE tline OCCURS 0 WITH HEADER LINE.
*-------------- Call Function
CALL FUNCTION 'CONVERT_OTFSPOOLJOB_2_PDF'
EXPORTING
src_spoolid = whatspoolid
TABLES
pdf = pdf
EXCEPTIONS
err_no_otf_spooljob = 1
OTHERS = 12.
*------------- Convert
PERFORM doconv TABLES pdf objbin.
ENDFORM. "ml_spooltopdf
* FORM
FORM doconv TABLES
mypdf STRUCTURE tline
outbin STRUCTURE solisti1.
*-------- Data
DATA : pos TYPE i.
DATA : len TYPE i.
*------------ Loop And Put Data
LOOP AT mypdf.
pos = 255 - len.
IF pos > 134. "length of pdf_table
pos = 134.
ENDIF.
outbin+len = mypdf(pos).
len = len + pos.
IF len = 255. "length of out (contents_bin)
APPEND outbin.
CLEAR: outbin, len.
IF pos < 134.
outbin = mypdf+pos.
len = 134 - pos.
ENDIF.
ENDIF.
ENDLOOP.
IF len > 0.
APPEND outbin.
ENDIF.
ENDFORM. "doconv
Then include that report in the following report and copy the same code and paste it there
*& Report ZPA_TEMP147 *
REPORT ZPA_TEMP147 .
INCLUDE zpa1_inclfor_mail.
* DATA
DATA : itab LIKE tline OCCURS 0 WITH HEADER LINE.
DATA : file_name TYPE string.
data : path like PCFILE-PATH.
data : extension(5) type c.
data : name(100) type c.
* SELECTION SCREEN
PARAMETERS : receiver TYPE somlreci1-receiver lower case.
PARAMETERS : p_file LIKE rlgrap-filename
OBLIGATORY.
* AT SELECTION SCREEN
AT SELECTION-SCREEN ON VALUE-REQUEST FOR p_file.
CLEAR p_file.
CALL FUNCTION 'F4_FILENAME'
IMPORTING
file_name = p_file.
* START-OF-SELECTION
START-OF-SELECTION.
PERFORM ml_customize USING 'Tst' 'Testing'.
PERFORM ml_addrecp USING receiver 'U'.
PERFORM upl.
PERFORM doconv TABLES itab objbin.
PERFORM ml_prepare USING 'X' extension name.
PERFORM ml_dosend.
SUBMIT rsconn01
WITH mode EQ 'INT'
AND RETURN.
* FORM
FORM upl.
file_name = p_file.
CALL FUNCTION 'GUI_UPLOAD'
EXPORTING
filename = file_name
filetype = 'BIN'
TABLES
data_tab = itab
EXCEPTIONS
file_open_error = 1
file_read_error = 2
no_batch = 3
gui_refuse_filetransfer = 4
invalid_type = 5
no_authority = 6
unknown_error = 7
bad_data_format = 8
header_not_allowed = 9
separator_not_allowed = 10
header_too_long = 11
unknown_dp_error = 12
access_denied = 13
dp_out_of_memory = 14
disk_full = 15
dp_timeout = 16
OTHERS = 17.
path = file_name.
CALL FUNCTION 'PC_SPLIT_COMPLETE_FILENAME'
EXPORTING
complete_filename = path
* CHECK_DOS_FORMAT =
IMPORTING
* DRIVE =
EXTENSION = extension
NAME = name
* NAME_WITH_EXT =
* PATH =
EXCEPTIONS
INVALID_DRIVE = 1
INVALID_EXTENSION = 2
INVALID_NAME = 3
INVALID_PATH = 4
OTHERS = 5
ENDFORM. "upl
Regards
Pavan -
How to send a file as an attachment using mailx
Hi
Can any one tel me how to send a file as an attachment using mailx command in shell script.
Thanks,
Suman.Wrong forum where to ask such questions.
Check this one link:
http://www.unix.com/shell-programming-scripting/18370-sending-email-text-attachment-using-mailx.html?t=18370#post70254 -
How do I scan a photo to a file and then send the file as an attachment via email.
How do I scan a photo to a file and then send the file as an attachment via email.
All of this depends largely on what printer /software you have, which Email client you use and to some extent which OS you are running.
Most HP printers have HP Solution Center which is used to set up scanning,choosing where to save,etc. Once a file/photo is scanned and saved to the folder, open the folder.Select the file and at the top of the window should be the option to 'Email'.
******Clicking the Thumbs-Up button is a way to say -Thanks!.******
**Click Accept as Solution on a Reply that solves your issue to help others** -
How to send text file as an email attachment havin more than 255 characters
My requirement is to generate a text file and to send this text file as E-mail attachment. I am using FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' to send the E-mail. but here the limitation is the number of characters per line must not be more than 255 characters whereas in my case it is exceeding 1000 characters per line. could anyone please suggest me what should i do now ? Each field in the text file has to be tab delimited.
Simplest might well be to use javamail API instead of the two tags that Sites provides, e.g. see email - Sending mail attachment using Java - Stack Overflow for a full example.
Phil -
How to send PDF file as an attachment in email?
Hi Folks,
I have successfully configured SMTP and by now I can successfully send normal text messages along with .TXT files. However, when I am trying to send an email along with .pdf file as an attachment, I am getting the mail in my inbox, but I cannot open the .pdf file! I am getting the following Acrobat error:
Acrobat could not open 'abc.pdf' because it is either not a supported file type or because the file has been corrupted
Can any help me in solving this problem?
Thanks in advance
Regards,
FaisalHi Vajha,
Thanks alot for your kind reply. I also express my apologies for responding to your reply lately.
I beleive all the links you have sent me are talking about ABAP coding. what I am interested in is,
is there any configuration that I am missing in SCOT (Basis side)?
Since I am not an ABAPER, so I carry out these activities.
Can anyone please answer the following queries of mine:
1. Can't we send any PDF attachment in a mail from R/3?
2. Do we have to do it through coding only?
3. In scot we have option "All formats except fllw". But it does not work for me. Any inputs?
Thanks in advance.
Regards,
Faisal -
Problem to send text file to mail from ALV report
Hi Friends,
I have a problem in my ALV report with text file. As per the requirment, when we execute the program then text attachment should go to the particual email.
When i am using file type as XLS i am getting attachment with all 4 recoreds( input for 4 records) in mail. But all 4 records are coming in SAME ROW. It should come 4 records in 4 rows. when I use file type as TXT and separated by pipe symble in code, it is showing only one recored for same above input.
When i use file type as XLS and click the attachment in email, it will triggire one popul with three options like SAVE, OPEN, CANCEL.
But when i click on text file attachment, it is directly showing ony one recored.
Please correct me on this.
my code is
PERFORM send_file_as_email_attachment
tables i_message
i_attach
using v_email
'User last log on details'
'XLS'
'User log on list'
changing v_error
v_reciever.
FORM send_file_as_email_attachment tables pi_message
pi_attach
using p_email
p_mtitle
p_format
p_filename
p_attdescription
p_sender_address
p_sender_addres_type
changing p_error
p_reciever.
DATA: l_error TYPE sy-subrc,
l_reciever TYPE sy-subrc,
l_mtitle LIKE sodocchgi1-obj_descr,
l_email LIKE somlreci1-receiver,
l_format TYPE so_obj_tp ,
l_attdescription TYPE so_obj_nam ,
l_attfilename TYPE so_obj_des ,
l_sender_address LIKE soextreci1-receiver,
l_sender_address_type LIKE soextreci1-adr_typ,
l_receiver LIKE sy-subrc.
l_email = p_email.
l_mtitle = p_mtitle.
l_format = p_format.
l_attdescription = p_attdescription.
l_attfilename = p_filename.
l_sender_address = p_sender_address.
l_sender_address_type = p_sender_addres_type.
Fill the document data.
v_doc_data-doc_size = 1.
Populate the subject/generic message attributes
v_doc_data-obj_langu = sy-langu.
v_doc_data-obj_name = 'SAPRPT'.
v_doc_data-obj_descr = l_mtitle .
v_doc_data-sensitivty = 'F'.
Fill the document data and get size of attachment
CLEAR v_doc_data.
READ TABLE i_attach INDEX v_cnt.
v_doc_data-doc_size =
( v_cnt - 1 ) * 255 + STRLEN( i_attach ).
v_doc_data-obj_langu = sy-langu.
v_doc_data-obj_name = 'SAPRPT'.
v_doc_data-obj_descr = l_mtitle.
v_doc_data-sensitivty = 'F'.
CLEAR i_attachment.
REFRESH i_attachment.
i_attachment[] = pi_attach[].
Describe the body of the message
CLEAR i_packing_list.
REFRESH i_packing_list.
i_packing_list-transf_bin = space.
i_packing_list-head_start = 1.
i_packing_list-head_num = 0.
i_packing_list-body_start = 1.
DESCRIBE TABLE i_message LINES i_packing_list-body_num.
i_packing_list-doc_type = 'RAW'.
APPEND i_packing_list.
Create attachment notification
i_packing_list-transf_bin = 'X'.
i_packing_list-head_start = 1.
i_packing_list-head_num = 1.
i_packing_list-body_start = 1.
DESCRIBE TABLE i_attachment LINES i_packing_list-body_num.
i_packing_list-doc_type = l_format.
i_packing_list-obj_descr = l_attdescription.
i_packing_list-obj_name = l_attfilename.
i_packing_list-doc_size = i_packing_list-body_num * 255.
APPEND i_packing_list.
Add the recipients email address
CLEAR i_receivers.
REFRESH i_receivers.
i_receivers-receiver = l_email.
i_receivers-rec_type = 'U'.
i_receivers-com_type = 'INT'.
i_receivers-notif_del = 'X'.
i_receivers-notif_ndel = 'X'.
APPEND i_receivers.
CALL FUNCTION 'SO_DOCUMENT_SEND_API1'
EXPORTING
document_data = v_doc_data
put_in_outbox = 'X'
sender_address = l_sender_address
sender_address_type = l_sender_address_type
commit_work = 'X'
IMPORTING
sent_to_all = v_sent_all
TABLES
packing_list = i_packing_list
contents_bin = i_attachment[]
contents_txt = i_message
receivers = i_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.
Populate zerror return code
l_error = sy-subrc.Hi,
declare the following constant in u r program and concatenate at the end of each and every record in your internal table.
CONSTANTS : LV_CRLF TYPE C VALUE CL_ABAP_CHAR_UTILITIES=>CR_LF.
for eg.
if u internal table has values like
row1
row2
row3
concatenate the 1st record lv_crlf into first record.
conactenate second record lv_crlf into second record.
concatenate third record lv_crlf into third record.
now attach the internal table to the FM which u use for sending email. Each and every row will come in new line. The LV_CRLF will hold nothing but a line feed character (#).
Hope it will solve u r problem
Regards,
Rose. -
Text file as an attachment in reciever mail adapter
Hi Experts,
I want to pick the text file using sender file adapter using file content converion, same file i need to send an attachment in reciever mail adapter.
Can anybody help me how can i do this.
Kind Regards,
Praveen.
Edited by: Praveen Kumar on Mar 10, 2010 9:08 AMHi,
>>>I want to pick the text file using sender file adapter using file content converion, same file i need to send an attachment in reciever mail adapter.
use payload swap bean to put the attachment in place of the message payload - do the content conversion using
content conversion adapter module, then do the same in the reverted order at the receiver
there are dozenz of blogs showing how to use the two adapter modules I mentioned so just do a little search in blog section
Regards,
Michal Krawczyk -
Problem in sending .doc file as an attachment.!
Hi SDN,
I am using FM 'SO_NEW_DOCUMENT_ATT_SEND_API1' to send a .doc file as an attachment i am filling the the table contents_hex with my internal table containing the data in hex format but the attachment coming to the SAP office inbox is not showing the actual data it's showing the file with all hex values.
can any one tell the reason?
Please give sample code if possible for sending a word file as an attachment..
Regards,
RahulHi Rahul,
I am sending you the sample code I have written for TXT.
you can use the same code for .doc with small modification.
You use this code and check once and let me know.
Sample code:
Declaration:
DATA : w_name TYPE sos04-l_adr_name.
DATA: sent_to_all LIKE sonv-flag.
DATA:
l_datum(10),
ls_docdata TYPE sodocchgi1,
lt_objpack TYPE TABLE OF sopcklsti1 WITH HEADER LINE,
lt_objhead TYPE TABLE OF solisti1 WITH HEADER LINE,
lt_objtxt TYPE TABLE OF solisti1 WITH HEADER LINE,
lt_objbin TYPE TABLE OF solisti1 WITH HEADER LINE,
lt_reclist TYPE TABLE OF somlreci1 WITH HEADER LINE,
lt_listobject TYPE TABLE OF abaplist WITH HEADER LINE,
l_tab_lines TYPE i,
l_tab_lines1 TYPE i,
l_tab_lines2 TYPE i,
l_att_type LIKE soodk-objtp.
CONSTANTS : c_tab TYPE x VALUE '09'. "tab delimiter between records.
CONSTANTS : c_line(2) TYPE x VALUE '0D'.
CONSTANTS : l_newline(2) TYPE x VALUE '0D0A'. "To insert Newline.
DATA: v_str LIKE lt_objbin.
*Program logic
Main Text
lt_objtxt = 'Dummy heading. ' .
APPEND lt_objtxt.
lt_objtxt = '' .
APPEND lt_objtxt.
lt_objtxt = 'Dummy second line.'.
APPEND lt_objtxt.
lt_objtxt = '' .
APPEND lt_objtxt.
lt_objtxt = 'Regards,'.
APPEND lt_objtxt.
lt_objtxt = 'Field Service Team' .
APPEND lt_objtxt.
lt_objtxt = '----
APPEND lt_objtxt.
lt_objtxt = 'This is system-generated email;please do not reply to this
message.' .
APPEND lt_objtxt.
lt_objtxt = 'If there are any questions regarding this error message'.
APPEND lt_objtxt.
lt_objtxt = '----
APPEND lt_objtxt.
Write Packing List (Main)
DESCRIBE TABLE lt_objtxt LINES l_tab_lines.
READ TABLE lt_objtxt INDEX l_tab_lines.
ls_docdata-doc_size = ( l_tab_lines - 1 ) * 255 + STRLEN( lt_objtxt ).
CLEAR lt_objpack-transf_bin.
lt_objpack-head_start = 1.
lt_objpack-head_num = 0.
lt_objpack-body_start = 1.
lt_objpack-body_num = l_tab_lines.
lt_objpack-doc_type = 'RAW'.
APPEND lt_objpack.
Create Message Attachment "Attachmant of file
LOOP AT itab1.
CONCATENATE itab1-bldat itab1-blart itab1-bukrs itab1-budat
itab1-monat itab1-waers itab1-xblnr itab1-bktxt
INTO lt_objbin SEPARATED BY c_tab .
CONCATENATE l_newline lt_objbin INTO lt_objbin.
APPEND lt_objbin.
CLEAR lt_objbin.
ENDLOOP.
Write Packing List (Attachment)
l_att_type = 'txt'.
DESCRIBE TABLE lt_objbin LINES l_tab_lines.
READ TABLE lt_objbin INDEX l_tab_lines.
lt_objpack-doc_size = ( l_tab_lines - 1 ) * 255
+ STRLEN( lt_objbin ).
lt_objpack-transf_bin = 'X'.
lt_objpack-head_start = 1.
lt_objpack-head_num = 0.
lt_objpack-body_start = 1.
lt_objpack-body_num = l_tab_lines.
lt_objpack-doc_type = l_att_type.
lt_objpack-obj_name = 'Header file name'.
lt_objpack-obj_descr = 'Header file name'.
APPEND lt_objpack.
*refresh bdclm. "Attachemnt of second file
CLEAR lt_objbin.
LOOP AT bdclm.
CONCATENATE itab2-indate itab2-intime itab2-tcode
itab2-longtext
INTO lt_objbin SEPARATED BY c_tab.
CONCATENATE l_newline lt_objbin INTO lt_objbin.
APPEND lt_objbin.
CLEAR lt_objbin.
ENDLOOP.
CLEAR lt_objbin.
Write Packing List (Attachment)
l_att_type = 'txt'.
DESCRIBE TABLE lt_objbin LINES l_tab_lines1.
l_tab_lines2 = l_tab_lines1 - l_tab_lines.
READ TABLE lt_objbin INDEX l_tab_lines2.
lt_objpack-doc_size = ( l_tab_lines2 - 1 ) * 255 + STRLEN( lt_objbin ).
lt_objpack-transf_bin = 'X'.
lt_objpack-head_start = l_tab_lines2.
lt_objpack-head_num = 0.
lt_objpack-body_start = l_tab_lines + 1.
lt_objpack-body_num = l_tab_lines2.
lt_objpack-doc_type = l_att_type.
lt_objpack-obj_name = 'file name '.
lt_objpack-obj_descr = 'file name '.
APPEND lt_objpack.
Create receiver list
lt_reclist-receiver = '[email protected]'.
lt_reclist-rec_type = 'U'.
APPEND lt_reclist.
Send Message
CALL FUNCTION 'SO_NEW_DOCUMENT_ATT_SEND_API1'
EXPORTING
document_data = ls_docdata
put_in_outbox = 'X'
commit_work = 'X '
*put_in_outbox = ''
IMPORTING
sent_to_all = sent_to_all
VALUE(NEW_OBJECT_ID) LIKE SOFOLENTI1-OBJECT_ID
TABLES
packing_list = lt_objpack
object_header = lt_objhead
contents_bin = lt_objbin
contents_txt = lt_objtxt
receivers = lt_reclist
*COMMIT_WORK = X
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.
Thanks,
Yuvaraj -
Sending Text File through Mail Adapter
Hi Group,
I need to send my Target as Mail attachment in the Text File?Can any body SuggestHi swabap,
You need to use PayloadSwapBean module in the Mail receiver adapter. This module will send the payload as an attchment to the mail server.
Check the following link
<a href="/people/prasad.ulagappan2/blog/2005/06/07/mail-adapter-scenarios-150-sap-exchange-infrastructure:///people/prasad.ulagappan2/blog/2005/06/07/mail-adapter-scenarios-150-sap-exchange-infrastructure
Regards,
Akshay -
Send text mail as an attachment
This is the code i'm using for send mail with text file as attachment
public class SendMailAttachment{
public static void main(String args[]) throws Exception{
try{
String host ="mail.akebonosoft.com";
String from = "[email protected]" ;
String to ="[email protected]";
String subject = "This is the subject!";
String message = "Message comes here!";
String localfile = "c:\\kalyan.doc";
String attachName = "kalyan.doc";
Authenticator auth =new SMTPAuthenticator();
Properties prop =System.getProperties();
prop.put("mail.smtp.host",host);
prop.put("mail.smtp.auth","true");
Session ses1 = Session.getDefaultInstance(prop,auth);
ses1.setDebug(true);
MimeMessage msg = new MimeMessage(ses1);
msg.setFrom(new InternetAddress(from));
msg.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
msg.setSubject(subject);
msg.setHeader("Content-Type","multipart/mixed");
// Create the message part
MimeBodyPart mbp1 = new MimeBodyPart();
// Fill the message
mbp1.setText(message);
mbp1.setHeader("Content-Type","text/plain");
MimeBodyPart mbp2 = new MimeBodyPart();
// Part two is attachment
FileDataSource source = new FileDataSource(localfile);
mbp2.setDataHandler(new DataHandler(source));
mbp2.setFileName(attachName);
mbp2.setHeader("Content-Type", "application/ms-word");
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(mbp1);
multipart.addBodyPart(mbp2);
msg.setSentDate(new Date());
msg.setContent(multipart);
Transport.send(msg);
catch(javax.mail.MessagingException me){
me.printStackTrace();
Exception ex = null;
if ((ex = me.getNextException()) != null) {
ex.printStackTrace();
problem is :
when I'm debugging I see the text file being parsed but I don't have see
any mails in outlook expresshi,
I can't still figure it out what was the problem.
This is the code
public class SendMailAttachment{
public static void main(String args[]) throws Exception{
try{
String host ="mail.akebonosoft.com";
String from = "[email protected]" ;
String to ="[email protected]";
String localfile = "c:\\sample.txt";
String attachName = "sample.txt";
Authenticator auth =new SMTPAuthenticator();
Properties prop =System.getProperties();
prop.put("mail.smtp.host",host);
prop.put("mail.smtp.auth","true");
Session ses1 = Session.getDefaultInstance(prop,auth);
ses1.setDebug(true);
MimeMessage msg = new MimeMessage(ses1);
msg.setFrom(new InternetAddress(from));
msg.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
msg.setSubject("This is the subject!");
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText("Message comes here!.");
Multipart multipart = new MimeMultipart();
multipart.addBodyPart(mbp1);
mbp1 = new MimeBodyPart();
FileDataSource source = new FileDataSource(localfile);
mbp1.setDataHandler(new DataHandler(source));
mbp1.setFileName(attachName);
multipart.addBodyPart(mbp1);
msg.setContent(multipart);
Transport.send(msg);
catch(javax.mail.MessagingException me){
me.printStackTrace();
Exception ex = null;
if ((ex = me.getNextException()) != null) {
ex.printStackTrace();
and this is the program trace
DEBUG: setDebug: JavaMail version 1.4ea
DEBUG: getProvider() returning javax.mail.Provider[TRANSPORT,smtp,com.sun.mail.smtp.SMTPTransport,Sun Microsystems, Inc]
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: useEhlo true, useAuth true
DEBUG SMTP: trying to connect to host "mail.akebonosoft.com", port 25, isSSL false
220 astserver3.akebonosoft.com Microsoft ESMTP MAIL Service, Version: 6.0.3790.1830 ready at Mon, 20 Nov 2006 17:29:18 +0530
DEBUG SMTP: connected to host "mail.akebonosoft.com", port: 25
EHLO ast75
250-astserver3.akebonosoft.com Hello [202.153.35.70]
250-TURN
250-SIZE
250-ETRN
250-PIPELINING
250-DSN
250-ENHANCEDSTATUSCODES
250-8bitmime
250-BINARYMIME
250-CHUNKING
250-VRFY
250-X-EXPS GSSAPI NTLM LOGIN
250-X-EXPS=LOGIN
250-AUTH GSSAPI NTLM LOGIN
250-AUTH=LOGIN
250-X-LINK2STATE
250-XEXCH50
250 OK
DEBUG SMTP: Found extension "TURN", arg ""
DEBUG SMTP: Found extension "SIZE", arg ""
DEBUG SMTP: Found extension "ETRN", arg ""
DEBUG SMTP: Found extension "PIPELINING", arg ""
DEBUG SMTP: Found extension "DSN", arg ""
DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
DEBUG SMTP: Found extension "8bitmime", arg ""
DEBUG SMTP: Found extension "BINARYMIME", arg ""
DEBUG SMTP: Found extension "CHUNKING", arg ""
DEBUG SMTP: Found extension "VRFY", arg ""
DEBUG SMTP: Found extension "X-EXPS", arg "GSSAPI NTLM LOGIN"
DEBUG SMTP: Found extension "X-EXPS=LOGIN", arg ""
DEBUG SMTP: Found extension "AUTH", arg "GSSAPI NTLM LOGIN"
DEBUG SMTP: Found extension "AUTH=LOGIN", arg ""
DEBUG SMTP: Found extension "X-LINK2STATE", arg ""
DEBUG SMTP: Found extension "XEXCH50", arg ""
DEBUG SMTP: Found extension "OK", arg ""
DEBUG SMTP: Attempt to authenticate
AUTH LOGIN
334 VXNlcm5hbWU6
a2FseWFuMTEz
334 UGFzc3dvcmQ6
Y2hha3Jp
235 2.7.0 Authentication successful.
DEBUG SMTP: use8bit false
MAIL FROM:<[email protected]>
250 2.1.0 [email protected] OK
RCPT TO:<[email protected]>
250 2.1.5 [email protected]
DEBUG SMTP: Verified Addresses
DEBUG SMTP: [email protected]
DATA
354 Start mail input; end with <CRLF>.<CRLF>
From: [email protected]
To: [email protected]
Message-ID: <17905416.01164023835660.JavaMail.Administrator@ast75>
Subject: This is the subject!
MIME-Version: 1.0
Content-Type: multipart/mixed;
boundary="----=_Part_0_24825485.1164023835535"
------=_Part_0_24825485.1164023835535
Content-Type: text/plain; charset=us-ascii
Content-Transfer-Encoding: 7bit
Message comes here!.
------=_Part_0_24825485.1164023835535
Content-Type: text/plain; charset=us-ascii; name=sample.txt
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename=sample.txt
Hi this is kalyan.
------=_Part_0_24825485.1164023835535--
250 2.6.0 <17905416.01164023835660.JavaMail.Administrator@ast75> Queued mail for delivery
QUIT
221 2.0.0 astserver3.akebonosoft.com Service closing transmission channel
Thus unable to get the mail in the outlook inbox -
hi
i've trying to send a text file via rs-232 but no success
The file contains a code for a device im dealing with, when i send the text file with labview to the device, it went ok with no errors, but when i connect the device on hyperterminal and check if the code was loaded it was not.
can you please give some clues to deal with this?
thanks a lot
attached example text file and LV code
Attachments:
Serial.JPG 45 KB
DefineHome.txt 1 KBSome devices are very picky with the End Of Line. You might want to right-click on your FIle Read and deselect the "Convert EOL".
Or if you need to write 1 line at a time, right click on the Read Text File and select "Read Lines". Set the number of line to read to -1 (read all) and then wire the resulting array into a FOR loop where you do the VISA Write.
There are only two ways to tell somebody thanks: Kudos and Marked Solutions
Unofficial Forum Rules and Guidelines
Maybe you are looking for
-
Oracle errors frm-40508 &ora-02291
hello i m having a problem i have two tables for my project with one of em master and the other a detail one i m using developer 2000 for frontend when i try inserting data in the forms developed i encounter an error frm-40508 which says "unable to i
-
How Does one Import at High Res?
I have not yet learned how to import my footage at a high resolution. What do i have to do to accomplish this?
-
Outer join style report - OBIEE 10g
Hi All, I have a requirement to generate a report for product & sales. I have two dimensions and various fact data elements. Some products may not be sold on a month but still i want to display them in the report with 0 value. I have tried this by cr
-
Handdoff don´t work
Handoff don't work on my macbook pro late 2011... I can see on the Mac when I have a phone call but I can't hear the caller and there is a strange noise. beside the calls, I don't see handoff working on any app. I have the Bluetooth on and on prefere
-
URL for donwloading a file ?
Hi, I have created a procedure i want to execute for downloading a file. In the URL link of the report I have made this URL : #OWNER#.dl_file?p_file=#PK# I want to execute this procedure. When I clok on the link I get this error message : "You don't