Hey I have this following code:

            // Connection props
            Properties props = new Properties();
            props.setProperty("mail.smtp.host", host);
            props.setProperty("mail.smtp.starttls.enable", "true");
            props.setProperty("mail.smtp.port", "25");
            props.setProperty("mail.smtp.user", usuario);
            props.setProperty("mail.smtp.auth", "true");
            // Prepare the session
            Session session = Session.getDefaultInstance(props);

            // Constuct the message
            MimeMessage message = new MimeMessage(session);
            /*Test*/   message.setHeader("Content-Type", "multipart/mixed");
            message.setFrom(new InternetAddress(CorreoOrigen));
            message.addRecipient(Message.RecipientType.TO,new InternetAddress(CorreoDestino));
            Multipart mp = new MimeMultipart(); 
            BodyPart texto=new MimeBodyPart();
            /*Test*/   texto.setHeader("Content-Type", "multipart/mixed");
            MimeBodyPart ajunto=new MimeBodyPart();
            ajunto.setHeader("Content-Type", "multipart/mixed");
         //   message.setContent(mp, "text/html");
            // We send it
            Transport t = session.getTransport("smtp");
            t.sendMessage(message, message.getAllRecipients());

            // Close.
        catch (Exception e)

Everytime I send it, it gets sent to the junk folder in Outlook 2007 and I rather it good directly to inbox. It contains simple text (nothing more, I put HTML in case we want to make it "prettier" in the future) and a attachment which can be a generated PDF or a generated ZIP. Once moved to the inbox, the PDF and the ZIP and be downloaded perfectly and opened and its content can be viewed so there is nothing stange or anything about it.

How can I fix this so it goes directly to the inbox? Thank you.

BTW, /*Test*/ lines did not work.

Edited 4 Years Ago by riahc3: n/a

I don't think there's anything you can do in your sending program to bypass Outlook's junk filtering rules. (If there was, then then junk filtering would be useless.)
You have to configure Outlook not to junk those messages, eg by white-listing the sender's domain.

Maybe it is YOU!
Junk mail filters usually work on WHERE e-mail is coming FROM (ie. your domain).

Edited 4 Years Ago by hfx642: n/a

Maybe it is YOU!
Junk mail filters usually work on WHERE e-mail is coming FROM (ie. your domain).

The thing is then why does the PDF work and not the zip...

Yes, you can whitelist/blacklist by the sender's name or domain, but there are a load of other ad-hoc algorithms used by Outlook's junk filter eg presence of certain keywords, or attachment types (pdf is generally "safer" than zip).

JamesCherrill is correct!
While *.pdf files are documents, *.zip files can contain an undesirable little "gem".

Damn......oh well. Ill include some details in the email but I dont like this "solution"....

This article has been dead for over six months. Start a new discussion instead.