PROBLEM OPENING ATTACHMENT SENT BY JAVA MAIL FROM OUTLOOK

Hi All,
I have a Java program sending an email with attached file. It works fine for all the files without any extension. If I attach a file with .java exetension, I can not open file from Out Look and get "Access Denied Message"
Please let me know.
Thanks.

I just tried sending a .java file with a class I wrote using JavaMail 1.2 and Outlook didn't have a problem with me opening the file.

Similar Messages

  • Java Mail - problems receiving HTML mail from outlook

    Hello,
    I have a problem with receiving HTML mails from outlook. What I want to do is the following
    - receiving a HTML mail - like a newsletter- send via Outlook
    - display the mail via my mail client in a jtextpane
    I tried it with the following code - but without success :
    a)
    Message msg = message;                    ByteArrayOutputStream os = new ByteArrayOutputStream();     
    message[i].getDataHandler().writeTo(os);
    String data = new String(os.toByteArray());
    textPane.setText(data);
    b)
    StringBuffer sb = null;
    Multipart mp = (Multipart)message[i].getContent();
    for (int j = 1; j < count; j++){
    sb = new StringBuffer();
    InputStream is = mp.getBodyPart(j).getInputStream();
    int c;
    while ((c = is.read()) != -1)
    sb.append((char) c);
    is.close();
    textPane.setText(sb.toString());
    Thanks,
    Mario

    This is what i use and it works just fine
    import java.io.*;
    import java.net.InetAddress;
    import java.util.Properties;
    import java.util.Date;
    import javax.mail.*;
    import javax.mail.internet.*;
    public class sendMail {
    public sendMail(String To,String Subject,String message) {
    String to = To, subject = Subject, from = null,
              cc = null, bcc = null, url = null;
         String protocol = null, host = null, user = null, password = null;
         boolean debug = false;
         try{
    Properties props = System.getProperties();
         Session session = Session.getDefaultInstance(props, null);
         Message msg = new MimeMessage(session);
         if (debug)
              session.setDebug(true);
    msg.setFrom(new InternetAddress("[email protected]"));
         msg.setRecipients(Message.RecipientType.TO,
                             InternetAddress.parse(to, false));
         msg.setSubject(subject);
    msg.setText(message);
         msg.setHeader("Mail","test.com");
         msg.setSentDate(new Date());
         Transport.send(msg);
         System.out.println("\nMail was sent successfully.");
         } catch (Exception e) {
         e.printStackTrace();

  • I'm using OS 10.6.8 and Mail 4.5. When I receive mails with attachments which are visible the save button doesn't work. Some contacts have problems opening files sent by me using Mail too. This was never a problem on pre-Intel. A real Mac **** up !

    I'm using OS 10.6.8 and Mail 4.5. When I receive mails with attachments which are visible the save button doesn't work. And some contacts occasionally have problems opening files sent by me using Mail too. This was never a problem on pre-Intel Mac. A real Mac **** up ! Any ideas ?

    Can you drag and drop the attachments visible in the email to the Desktop OK or does that fail ?
    Re the sending: Are these recipients on Mac's or PC's as the file type could be an issue, if on Mac's then try setting the Mail Preferences Composing setting to Plain Text not Rich Text and see if that improves things.

  • Sent myself a vcard from outlook to my iphone. It is coming through as a dat file and won't open. In the past I have done this and it comes through as a vcf with no problems. Any ideas?

    Sent myself a vcard from Outlook so I can open it on my I phone. These have always in the past come through as vcf and I have been able to open and save them. Today no matter what I do they are coming through as dat files. Any ideas?

    Use Plain Text for the sent message, not HTML or RTF.
    http://www.fileinfo.com/help/winmail_dat_files

  • Problem in sending messages using java mail api

    Hi All,
    I have a problem in sending messages via java mail api.
    MimeMessage message = new MimeMessage(session);
    String bodyContent = "ñSunJava";
    message.setText (bodyContent,"utf-8");using the above code its not possible for me to send the attachment. if i am using the below code means special characters like ñ gets removed or changed into some other characters.
    MimeBodyPart messagePart = new MimeBodyPart();
                messagePart.setText(bodyText);
                // Set the email attachment file
                MimeBodyPart attachmentPart = new MimeBodyPart();
                FileDataSource fileDataSource = new FileDataSource("C:/sunjava.txt") {
                    public String getContentType() {
                        return "application/octet-stream";
                attachmentPart.setDataHandler(new DataHandler(fileDataSource));
                attachmentPart.setFileName(filename);
                Multipart multipart = new MimeMultipart();
                multipart.addBodyPart(messagePart);
                multipart.addBodyPart(attachmentPart);
                message.setContent(multipart);
                Transport.send(message);is there any way to send the file attachment with the body message without using MultiPart java class.

    Taken pretty much straight out of the Javamail examples the following works for me (mail read using Thunderbird)        // Define message
            Message message = new MimeMessage(session);
            message.setFrom(new InternetAddress(from));
            // Set the 'to' address
            for (int i = 0; i < to.length; i++)
                message.addRecipient(Message.RecipientType.TO, new InternetAddress(to));
    // Set the 'cc' address
    for (int i = 0; i < cc.length; i++)
    message.addRecipient(Message.RecipientType.CC, new InternetAddress(cc[i]));
    // Set the 'bcc' address
    for (int i = 0; i < bcc.length; i++)
    message.addRecipient(Message.RecipientType.BCC, new InternetAddress(bcc[i]));
    message.setSubject("JavaMail With Attachment");
    // Create the message part
    BodyPart messageBodyPart = new MimeBodyPart();
    // Fill the message
    messageBodyPart.setText("Here's the file ñSunJava");
    // Create a Multipart
    Multipart multipart = new MimeMultipart();
    // Add part one
    multipart.addBodyPart(messageBodyPart);
    // Part two is attachment
    for (int count = 0; count < 5; count++)
    String filename = "hello" + count + ".txt";
    String fileContent = " ñSunJava - Now is the time for all good men to come to the aid of the party " + count + " \n";
    // Create another body part
    BodyPart attachementBodyPart = new MimeBodyPart();
    // Get the attachment
    DataSource source = new StringDataSource(fileContent, filename);
    // Set the data handler to this attachment
    attachementBodyPart.setDataHandler(new DataHandler(source));
    // Set the filename
    attachementBodyPart.setFileName(filename);
    // Add this part
    multipart.addBodyPart(attachementBodyPart);
    // Put parts in message
    message.setContent(multipart);
    // Send the message
    Transport.send(message);                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Can't sent mail from outlook

    I'm a mac.com acount user. for a long time.
    This changed to me.com and later to Icloud.com.
    Since my storage has been set lower on 5GB on 30 sept 2013 its not possible anymore to sent mail from outlook.
    On the 30 sept we got a message to delete some files in the icloud because our memory was to high.
    But after changing to enough space the problems did not go away.
    error: 0x80004005 de bewerking mislukt.
    I can receive all mails from all my .mac and .me accounts.
    And I can sent mails from outlook .com, but I don't want to use that
    Can someone explain what happened and how to make it work
    Thx
    John

    Allan - Here's the other odd thing. Currently, I have my old mail account AND my new MM account both feeding into and out of Outlook. But since adding my MM acct. - even though I set it as my default mail acct. - the hierarchy tree of Outlook folders is still treating my old acct. as king and my new MM acct. as second class. I know, what's that mean? I have my overriding "Personal Folders" folder, with the sub-folders (in addition to customized ones I added) - all of these at the same level - 'Deleted Items'; 'Inbox' (for my old account); 'Junk E-mail'; 'RSS Feeds'; 'Sent Items' and "Search Folders". Then, below that, but at the same hierarchy level as "Personal Folders", I have my MM's root of an IMAP store folder that has as its name my email address, including the "@me.com". Under that, at the same level of importance as my 'Deleted Items', etc. for my old account is my MM account's "Inbox", "Junk E-mail", "Sent" (which, like I said, I created when I sent the first email from my newly created MM account), and "Search Folders"... that's it. If I delete an email from my MM acct., or am in the process of creating an email in my MM acct., I can only find it in the aforementioned "Deleted Items" or "Draft" folders, as my MM acct. doesn't have these. Is this perhaps one indicator of my sent mail synching problem? Or does one have nothing to do with the other? Does Outlook only provide one each of "Drafts", "Deleted Items" and "Outbox" that all accounts share?

  • Problem sending mail from OUTLOOK

    Hi !
    I use the following code to send mails from outlook:
    Process p = Runtime.getRuntime().exec(new String[]{"cmd.exe","/c", "start","mailto:[email protected]?body=test"});
    and it works, but my problem is that if I add any other attribute like cc,subject only the first one it's done, I mean, If I do:
    Process p = Runtime.getRuntime().exec(new String[]{"cmd.exe","/c", "start","mailto:[email protected]?subject=subject_test&body=test"});
    subject will appear properly but body will be empty.
    Where is the problem??
    Thanks!!
    TLLI

    Okay, I was mistaken, I thought about this thread. Might still be helpful to you, especially the JDIC reference:
    http://forum.java.sun.com/thread.jspa?forumID=31&threadID=641669

  • Problem in using 'ReceivedDateTerm' in Java Mail

    Hi there,
    I have problem in using 'ReceivedDateTerm' in Java Mail. I am able to search on all other criterias but when I try any kind of date search I don't get any message back. For example I send an email and then I try to search that email using the following code I don't get any message back:
    ReceivedDateTerm dateTerm = new ReceivedDateTerm(ComparisonTerm.EQ, new Date());
    SearchTerm term = dateTerm;
    // Other code
    // Get messages
    Message[] msgs = folder.search(term);
    Please help???
    Thanks & Regards,
    Ajay Singh

    The documentation for those classes is absolutely horrible. For example it doesn't say whether the time component of the Date is used, or ignored. It's possible you are asking to find all messages that were received at the exact millisecond you ran that code.

  • How to get All Mails from outlook

    Hi am reading mail from outlook.. It reads only unread mails. But i want to read all mails. if any one knows please help me..My code is..
    import javax.mail.*;
    import javax.mail.internet.*;
    import java.util.*;
    import java.io.*;
    public class AllPartsClient {
      public static void main(String[] args) {
    Properties props = new Properties();
        String host = "myhost";
        String username = "myuser";
        String password = "mypass";
        String provider = "pop3";
        try {
          Session session = Session.getDefaultInstance(props, null);
          // Connect to the server and open the folder
          Store store = session.getStore(provider);
          store.connect(host, username, password);
          Folder folder = store.getFolder("INBOX");
          if (folder == null) {
            System.out.println("Folder " + folder.getFullName() + " not found.");
            System.exit(1);
        folder.open(Folder.READ_ONLY);
          // Get the messages from the server
          Message[] messages = folder.getMessages();
          for (int i = 0; i < messages.length; i++) {
            System.out.println("------------ Message " + (i+1)
             + " ------------");
            // Print message headers
            Enumeration headers = messages.getAllHeaders();
    while (headers.hasMoreElements()) {
    Header h = (Header) headers.nextElement();
    System.out.println(h.getName() + ": " + h.getValue());
    System.out.println();
    // Enumerate parts
    Object body = messages[i].getContent();
    if (body instanceof Multipart) {
    processMultipart((Multipart) body);
    else { // ordinary message
    processPart(messages[i]);
    System.out.println();
    // Close the connection
    // but don't remove the messages from the server
    folder.close(true);
    catch (Exception e) {
    e.printStackTrace();
    // Since we may have brought up a GUI to authenticate,
    // we can't rely on returning from main() to exit
    System.exit(0);
    public static void processMultipart(Multipart mp)
    throws MessagingException {
    System.out.println("mp.getCount() = "+mp.getCount());
    for (int i = 0; i < mp.getCount(); i++) {
    processPart(mp.getBodyPart(i));
    public static void processPart(Part p) {
    try {
    String fileName = p.getFileName();
    String disposition = p.getDisposition();
    String contentType = p.getContentType();
    if (fileName == null && (Part.ATTACHMENT.equals(disposition)
    || !contentType.equalsIgnoreCase("text/plain"))) {
    // pick a random file name. This requires Java 1.2 or later.
    fileName = File.createTempFile("attachment", ".txt").getName();
    if (fileName == null) { // likely inline
    p.writeTo(System.out);
    else {
    File f = new File(fileName);
    // find a version that does not yet exist
    for (int i = 1; f.exists(); i++) {
    String newName = fileName + " " + i;
    f = new File(newName);
    FileOutputStream out = new FileOutputStream(f);
    // We can't just use p.writeTo() here because it doesn't
    // decode the attachment. Instead we copy the input stream
    // onto the output stream which does automatically decode
    // Base-64, quoted printable, and a variety of other formats.
    InputStream in = new BufferedInputStream(p.getInputStream());
    int b;
    while ((b = in.read()) != -1) out.write(b);
    out.flush();
    out.close();
    in.close();
    catch (Exception e) {
    System.err.println(e);
    e.printStackTrace();
    In this code if Content is Multipart then it is not displaying content..
    Thanks

    Hi
    if i use String provider = "imap"; then it shows the following error message..
    javax.mail.MessagingException: Connection refused: connect
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:479)
    at javax.mail.Service.connect(Service.java:275)
    at javax.mail.Service.connect(Service.java:156)
    at javamail.AllPartsClient.main(AllPartsClient.java:39)
    Caused by: java.net.ConnectException: Connection refused: connect
    at java.net.PlainSocketImpl.socketConnect(Native Method)
    at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)
    at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)
    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)
    at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:364)
    at java.net.Socket.connect(Socket.java:507)
    at java.net.Socket.connect(Socket.java:457)
    at com.sun.mail.util.SocketFetcher.createSocket(SocketFetcher.java:232)
    at com.sun.mail.util.SocketFetcher.getSocket(SocketFetcher.java:189)
    at com.sun.mail.iap.Protocol.<init>(Protocol.java:84)
    at com.sun.mail.imap.protocol.IMAPProtocol.<init>(IMAPProtocol.java:87)
    at com.sun.mail.imap.IMAPStore.protocolConnect(IMAPStore.java:446)
    ... 3 more
    pls any one give idea

  • Event of Sending Mail From Outlook Integration Add-On

    Dear Experts,
    I am not able to find the event if I am sending mail from outlook integration add-on. Suppose I open a Sales Order that already entered and click on Mail Menu and click on 'Send' Button (Form Type = 188). It sends the mail successfully from Outlook but I am not able to use the event after that while it shows me operation completed successfully.
    I am writting it as follows:
    if (pVal.FormType == 188 && pVal.ActionSuccess == true && pVal.EventType == BoEventTypes.et_ITEM_PRESSED && pVal.ItemUID == "1")
    I have used it on Form Data Event too but no success.
    if (BusinessObjectInfo.BeforeAction == false)
                    switch (BusinessObjectInfo.EventType)
                        case BoEventTypes.et_FORM_DATA_ADD:
                                switch (BusinessObjectInfo.FormTypeEx)
                                            Case "188":
                                            }break;
    Plz help me.
    Regards

    Hi,
    Thanks for replying.
    I want a report that how many times a mail is sent against an Order.
    What i am doing:
    1. Open particular Sales Order.
    2. Click Mail Menu
    3. Click Send Button.
    4. Here comes an Popup box that a third party is trying to send a mail coz I am using outlook integration add-on to send mail. I allow it to send the mail.
    5. Mail is send successfully. I got the status bar message also.
    Now I want to write my event but not able to do that.
    plz reply now.
    Regards

  • Can't send or receive mail from Outlook

    just purchased a wireless router and hooked up recently. Can access the internet & outlook express but can't get my mail from outlook which is my main email account. Message says can't find exchange server. I can access Outlook from my laptop wirelessly at work but not at home.
    Any suggestions?

    checked the ip address of the computer when its connected to the router using the command promt.(example.....ip address: 192.168.1.100; Default Gateway:192.168.1.1).
    Open an internet browser (ie, mozilla, netscape,etc.). Type at the address bar the default gateway (192.168.1.1). and you will see a username and password promt for your router. Leave the username blank and use admin for your password, if it doesn't work use the password you setup the router to..
    Once you see the setup page.... you'll be at basic setup sub tab under setup. Look for MTU. Set it to MANUAL and LOWER IT TO 1300.  Save the settings. Check your outlook if its working....If its Does't work do this
    Go to Applications and Gaming tab.
    Look for a port triggering sub tab. type it this way
    Application NameTrigger Port RangeIncoming Port Range
    application       triggered range     forwarded range
    E-mai                 l25 ~ 25                   113 ~ 113
    forwarded range is equevalent to incoming port rage...
    hope this will solve your concern.... 

  • How to skip dialogue box which ask you to confirm the operation when your used labview to send an e-mail from Outlook?

    I'm using Labview to send an e-mail from outlook and everytime I got a dialogue box which inform that a software is trying to send an e-mail. To send this e-mail I have to confirm operation. How can I avoid this dialogue box ?

    I don't know what code you're using but the attached VI works with my version of Outlook and doesn't have any pop-up messages. I downloaded it from somewhere a while ago but don't remember where it was from.
    Attachments:
    Email_sender.vi ‏54 KB

  • Migrate Mails From Outlook (mac) To Outlook (windows) ?

    Hi Everybody,
    I am in search of best solution for transferring mails from outlook (mac) to outlook (windows). There are a lot of mails that i need to transfer. I have looked into many forums for the solutions but most are for making IMAP account and all. I don't have such
    a good technical hand in doing such stuff, so i am looking for other alternatives. Fast and Problem solving answers will be really appreciated.
    Thank you

    just needed to add alittle info in this thread...
    I was also looking for solution to import my outlook for mac mails to windows outlook and I was taken to olm to pst converter pro website via this thread. 
    The information that i wanted to add is that Olm to pst converter pro is available in mac version too, which allowed me to convert outlook for mac files into pst format in just a few clicks and  the only thing I had to do is transfer the converted
    pst file and import it into windows outlook.
    I got this tool here: http://olmtopstconverterpro.com/download-olm-to-pst-converter-pro-instant-digital-download/
    Tha whole process was completed in merely 15-18 mins which is the fastest results I have found til now. I hpoe that in information also helps other looking for solution to migrate outlook for mac files to windows outlook.
    Thank you

  • How to exchange E-mail from Outlook?

    After an update of the software of the N97 to version 12, I had to install again the exchange option with Outlook. Contacts, Agenda, Tasks, ... works fine, but I can't get the mail exchange working again.
    My purpose is just to load the mails of say 5 days from Outlook into the N97. In the Ovi Suite I have chosen: 
    Nokia PC sync instellingen: I have chosen E-mail, too; folder: Inbox; exclusief e-mails bigger than 200 kb.
    I think I do something wrong on the N97-side (and can't remember what I did right the very first time).
    Is it right to chose a mailbox: @home
    use as a usernaam the name I use in Outlook
    use as a password the password I use in Outlook
    use the same server for incoming mails as I use in Outlook
    use a standardconnection
    Mailboxname: the name after @Home
    use as Mailboxtype the same I use in Outlook: POP3
    use as port: standard?
    First I would like to have this working.
    Even better would be if I could use two mailboxes: 1 for e-mails from Outlook; 2 for e-mails from a different source via internet.
    Message Edited by loriot on 22-Sep-2009 05:08 PM

    As I can't believe that no one here knows the anwser, I think my description and/or title is unclear.
    It's about synchronization between the N97 and Outlook, but the problem I have only with synchronizing E-mails between the N97 and Outlook; synchronizing agenda, contacts, tasks, ... works well. 
    Message Edited by loriot on 23-Sep-2009 07:01 AM

  • Archiving E-mails from Outlook 11

    In Windows versions it was possible to Archive E-mails from Outlook into one acrobat file. This was so useful and was a great way to clear out old projects and e-mails that might be needed at a later date. I have spent a small fortune in moving from Windows to MAC with also purchasing Office and Acrobat Pro to now find problems such as this is very annoying .
    I see in the Adobe Video a link to combine E-mails into a PDF. But its not there on my MAC. Will there be an update to address this very useful feature or am I missing something.

    I wouldn't hold your breath waiting. Many of us have been trying to get the Acrobat team to give more feature equity with Windows for years. The Acrobat team is mainly focused on the Enterprise market, and they haven't yet learned that more Enterprise customers are moving to the Mac. Maybe by Acrobat 20!

Maybe you are looking for