Hey I have this following code:

try
        {
            // 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));
            
            message.setSubject(asunto);
       
            
            Multipart mp = new MimeMultipart(); 
            BodyPart texto=new MimeBodyPart();
            /*Test*/   texto.setHeader("Content-Type", "multipart/mixed");
            texto.setContent(mensaje,"text/html");
            mp.addBodyPart(texto);
            MimeBodyPart ajunto=new MimeBodyPart();
            ajunto.setHeader("Content-Type", "multipart/mixed");
            ajunto.attachFile(NombreArchivo);
            mp.addBodyPart(ajunto);
            
            message.setContent(mp);
            
         //   message.setContent(mp, "text/html");
            
            // We send it
            Transport t = session.getTransport("smtp");
            t.connect(usuario,contraseña);
            t.sendMessage(message, message.getAllRecipients());

            // Close.
            t.close();
        }
        catch (Exception e)
        {
            e.printStackTrace();
        }
    }

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.

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.

The PDF now goes to the inbox for some reason....

Member Avatar for hfx642

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

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).

Member Avatar for hfx642

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"....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.