How to attach a word file in JAVA mail

I am a JAVA rookie and I have a problem in attaching a word file using javamail. I searched almost all the forum but still couldn't find the solution.
Sorry for the reposting. But can anybody please help me out? Your any words or links will be highly appreciated!
Lakobe

Sorry, this forum is for questions about the javadoc tool.
There won't likely be JavaMail experts here.
I'm not sure where else to send you.

Similar Messages

  • How to attach a word file in JAVA mail? Please help

    I am a JAVA rookie and I have problem attaching a word file using javamail. I searched almost all the forum but still couldn't find the solution.
    Sorry for the reposting. But can anybody please help me out? Your any words or links will be highly appreciated!
    Lakobe

    If you want to include an attachment with your message, you need to build up the parts, quite literally, because the name of the applicable interface is Part. The content of your Message will consist of multiple parts within a Multipart object. Part one of the message is a BodyPart that contains the message content. Part two of the message is a BodyPart that contains the attachment. The attachment itself is specified as a DataSource. You don't have to actually read the attachment.
    You start in the same way as you do for a message without an attachment. Create the message from the session and initialize the headers:
    Message message = new MimeMessage(session);
    message.setFrom(new InternetAddress(from));
    message.addRecipient(Message.RecipientType.TO,
    new InternetAddress(to));
    message.setSubject("JDC Attachment");
    However here you need to create the Multipart object:
    Multipart multipart = new MimeMultipart();
    For part one, create a BodyPart and set the text to be a message. Then, add the BodyPart to the Multipart you just created.
    BodyPart messageBodyPart = new MimeBodyPart();
    messageBodyPart.setText("Here's the file");
    multipart.addBodyPart(messageBodyPart);
    For part two, you need to create a BodyPart again, but this time you need to create a DataSource for the file.
    messageBodyPart = new MimeBodyPart();
    DataSource source = new FileDataSource(filename);
    Use a DataHandler object to attach the data source to the message. Simply create a DataHandler for the source and attach it to the message:
    messageBodyPart.setDataHandler(
    new DataHandler(source));
    Remember to set the filename of the attachment. This permits the recipient to know the name (and type) of the received file.
    messageBodyPart.setFileName(filename);
    Attach part two in the same way as part one:
    multipart.addBodyPart(messageBodyPart);
    And as a final step before sending, attach the Multipart to the Message:
    message.setContent(multipart);

  • Can any one tell me how to attach a pdf file to the mail through workflow

    I have a smart which i am able  to convert it to a pdf file...now.. can any one tell me how to attach a pdf file to the mail through workflow

    Hi,
    To create the task for attachment
    Use the BOR SELFITEM and method NOTES_APPEND.
    The out come of this task contain a link called attachment with a clip attached. Clisk on that icon and choose the type of attachment u want . RAW , EXCEL , TXT , PDF... Then using the import icon u can attach the document u like.
    But the TYPE : OBJ.
    Similarly using NOTE_DISPLAY method u can display the documents u like.
    In any work item u have the facility to attach any atttchment for further circulation .
    Attchment @ WORKITEM
    1.Click the workitem for which you want to create the attchment
    2.Press create attachment
    3. Add the attachment u like (PDF)
    Reward points for useful answer.
    Richard A

  • How to attach a single file in e-mail (Yosemite)?

    When i am writing a new mail and i try to attach a single file that i have saved a minute ago from certain folder i cannot do that. When i click on the folder to open it and select the specific file to attach, the mail does not open the folder but automatically attach the whole folder to e-mail.
    Any help?
    Thanks.

    Hello dejanfromzagreb,
    That is interesting that it is grabbing the entire folder. Have you tried switching the view within the Finder window to Column View to select the right file to attach? Another alternative is to locate the file in Finder and drag it op top of the Email that you are preparing to attach it. Take a look at the article below. 
    Mail (Yosemite): Add attachments
    https://support.apple.com/kb/PH19142
    Regards,
    -Norm G. 

  • How to parse a MS word file from JAVA

    How do i read the contents of MS word file in java? I know that FileInputStream can be used to read the contents in bytes but i need to parse the content of the file also so any pointers on this would be helpful for me.
    I have tried out the API given out by POI by apache but i am not able to figure any thing out of that so it would be very helpful if some posts a sample code for the above problem.

    but i am not able to figure any thing out of thatUse XML, as DrLJ just proposed. But be warned that if you are going to be dealing with Word documents you will have to spend some time learning how they are formatted, even the XML versions. Don't expect to just throw down a FileInputStream and have things happen automagically. It's a complicated format.

  • 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>

  • How to read MS Word file

    Hi,
    How can i read MS word file in java ? My problem is that want to read .doc file and convert this .doc file into .txt tile . I was try with Jakarata POI , but i m not found out POI ?
    How to use Jakarata POI for reading .doc file ?
    Thanks in advance
    madhu
    [email protected]

    I believe your looking for the <input type="file" tag to read a file from the user's browser to the servlet. There are examples of this on line. POI is used after the file is read into the servlet to extract its information.

  • How to read an ARPA file in java

    Hi
    Im new in java and dont know many thing about it, I want to know how can read an ARPA file in java.
    pleas describ it step bye step and esy to understand.
    Edited by: 836719 on Feb 14, 2011 8:15 PM

    836719 wrote:
    ok i explain what i want to do maybe u can help me more,
    i want to read an arpa file and search it to find for example a word.so u think which method that u mentioned above is beter???
    It will be pleasure if u have any tip that can help me.1. Learn the basics of programming as well as how to logically construct and deconstruct a problem domain.
    2. Learn the basics of programming java.
    3. Learn about java.io.*
    4. Learn about java swing
    5. Find documentation that describes the format of the ARPA file.
    6. Read the documentation and understand it.
    7. Find a source for ARPA files (if this is online then there is more java to learn as well.)
    8. Use 1,2 and 3 to write java code that consumes the ARPA file.
    9. Use 4 to ask the user for a word.
    10. Use 1 and 2 to write code that 'searches' what you read in 8.

  • Uplod word file from java

    how we upload word file from java web page?? pls is urgent.

    > i not understand. pls explain?
    Ok. Take a look at the Fundamentals-forum where your post is in. If you look at the 30 most recent threads there are more tthen 10 thread about uploading files. A couple of those have some usefull answers which you probably can use.
    It's always a good habit to search a forum first before you post your question.
    Good luck.

  • Word Files in Java

    Hi everybody,
    I know this question has probably been asked a zillion and one times before, but I think I might be putting a bit of a new spin on it.
    Anyway, I was looking at the Jakarta API's to read and write Microsoft Word Files in Java, and I couldn't make heads or tails of them. Since they have packages you import, though, that means that there must be some Java solution to the problem. So, my question is this--does anyone here know of any Java stream classes, depreciated or otherwise, that can read Microsoft Word's encoding? I've heard rumors that some depreciated classes might be able to do the job; if I'm just completely wrong I'd appreciate it if someone would correct me so I'm not clinging to false hope. Failing an answer to that question, does anyone know if it's possible to get source code of the Jakarta packages?
    Thanks,
    Jezzica85

    Thanks TuringPest,
    I feel a bit stupid for saying this, but I can't make any sense of their source code either or tell which files are supposed to be for Microsoft Word; maybe it's just because of how it's written.
    What exactly does a proprietary format mean? I think I've heard the term, but I'm not sure.
    I'm starting to think my idea of writing some of my own code is too ambitious, but I thought this might be simple. All I want to do is get text out of a Word file, I don't want to open a file to edit it, and I don't care about formatting. Maybe if I understood the file format I could get myself started, I hope I don't sound like a broken record.
    Actually, I've written a macro into Microsoft Word that saves as a text file, so I can do it that way, I was just hoping there might be an easier way so I wouldn't need to deal with the extra file--is this probably the best way to go anyway?
    Thanks again,
    Jezzica85
    Message was edited by:
    jezzica85

  • Attach a word file into transaction me52n

    Hi all,
    i have a report that should  attach a word file into transaction me52n.
    is anyone know how can i do that?
    thanks in advanced,
    dana.

    You can attach documents to purchase orders using the object services button that appears by itself on the title line of the screen above the normal button bar.
    To do this in a program - there are a number of class methods - look at classes beginning with CL_GOS*
    Andrew

  • How to call a .bat file from java code?

    How to call a .bat file from java code? and how can i pass parameters to that .bat file?
    Thanks in advance

    thanks for ur reply
    but still i am getting the same error.
    I am trying to run a .bat file of together tool, my code looks like below
    import java.lang.Runtime;
    import java.lang.Process;
    import java.io.File;
    class SysCall{
         public static void main(String args[]){
              String cmd="D://Borland//Together6.2//bin//Together.bat -script:com.togethersoft.modules.qa.QA -metrics out:D://MySamples//Metrics// -fmt:html D://Borland//Together6.2//samples//java//CashSales//CashSales.tpr";
              //String path="D://Borland//Together6.2//bin//Together.bat ";
              Runtime r= Runtime.getRuntime(); //Declare the system call
              try{
                   System.out.println("Before batch is called");
                   Process p=r.exec(cmd);
                   System.out.println(" Exit value =" + p.exitValue());
                   System.out.println("After batch is called");
              /*can produce errors which must be caught*/
              catch(Exception e) {
                   e.printStackTrace();
                   System.out.println (e.toString());
    I am getting the below exception
    Before batch is called
    java.lang.IllegalThreadStateException: process has not exited
    at java.lang.Win32Process.exitValue(Native Method)
    at SysCall.main(SysCall.java:17)
    java.lang.IllegalThreadStateException: process has not exited

  • How to create a Batch file for java application  ?

    HI,
    How to create a Batch file for java application ?
    And whats the use of creating batch file ?
    Thanks in advance

    [http://static.springsource.org/spring-batch/]
    Assuming you want to develop a batch application rather than actually just create a .bat file ..

  • HOw to create a Batch file for java application and whats the use of this ?

    HI,
    How to create a Batch file for java application ?
    And whats the use of creating batch file ?
    Thanks in advance

    First of all, you're OT.
    Second, you can find this everywhere in the net.
    If you got a manifest declaring main class (an classpath if needed), just create a file named whatever.bat, within same directory of jar file, containing:
    javaw -jar ./WhateverTheNameOfYourJarIs.jar %*By the way, assuming a Windows OS, you can just double click the jar file (no batch is needed).
    Otherwise use:
    javaw -cp listOfJarsAndDirectoriesSeparedBySemiColon country/company/application/package/className %*Where 'country/company/application/package/' just stands for a package path using '/' as separator instead of '.'
    Don't specify the .class extension.
    Javaw only works on Windows (you asked for batch, I assumed .BAT, no .sh), in Linux please use java.exe (path may be needed, Windows doesn't need it 'cause java's executables are copied to system32 folder in order to be always available, see PATH environment variable if you don't know what I'm talking about) and use ':' as classpath (cp) separator.
    The '%***' tail is there in order to pass all parameters, it only works on Windows, refer to your shell docs for other OSs (something like $* may work).
    This way you have a command you can call to launch your code (instead of opening NetBeans just to see your app working). You could schedule tasks on it or just call it in any command prompt (hope you know what it is 'cause there have been people in this very same forum with no clue about it, if not just hold the 'Windows button' and press 'R', then type 'cmd' and run it).
    Finally add dukes and give 'hem away.
    Bye.

  • How to create the exe file for java project.

    How to create the exe file for java project.
    am done the project in java swing , i like to create the project in exe format, so any one help for me,
    send the procedure for that.
    thanking u.

    How to create the exe file for java project.Have you ever heard of google? I pasted your exact "question" into a google search:
    http://www.google.com/search?q=How+to+create+the+exe+file+for+java+project.
    and got several useful links.
    Better search terms might yield even better results.
    Sheesh.

Maybe you are looking for

  • Purchase Order

    Hi all, i have two doubts related to the purchase order. 1. How to know the Status of the purchase order ex: Open , Closed 2. How to get the Purchasing Quantity (KOMV-KAWRT) Please Advice me.. Many thanks for all of your help. Regards, Lakshma.

  • What are the correct Send Connectors settings in Exchange 2013

    Hi I'm new to exchange, successfully setup a lab with 2 cashub roles and 2 mailbox roles. I am trying to set the send connectors settings, because I've not been able to send nor receive external email via owa. Since I'm separating the exchange roles,

  • Insufficient bandwidth with USB mic

    Dual 2G G5, plenty RAM. OS 10.4.5 Dreaded "insufficient bandwidth" message appears although I checked the firewall settings, quicktime settings, restarted. I haven't a clue what is going on. Any suggestions?

  • Tuning related error using TOAD ?

    Hi, In my TOAD , in status option , it is showing Library cache get hit ratio : 64.6448 : Dynamic or Unsharable SQL (RED Colored) Chained Fetch Ratio - 0.0912 - PCTFREE too low for a table (RED colored) Parse to Execute Ratio - 37.5033 : High parse t

  • Error while testing Inbound INVOIC with we19

    Hello Friends, I want to test inbound invoic with we19. I get now the mistake : external sender not avaiable (status 51) (translated from the german : Externer Sender wurde nicht angegeben). I guess the INVOIC-Idoc ist correct. Whal could it be? than