Hi, I can send an email using Slide through MS exchange server but have
problems to add attachment. I used the code below but always with status
code 403 returned. I suppose attachment can be added to the message body.
Any idea? Thanks in advanced.

Xiaobo Yang

             PutMethod putMethod = new PutMethod(sUri); // sUri - mail
submission uri
                         putMethod.setRequestHeader("MIME-Version", "1.0");
                         String boundary = "lalala";
                         putMethod.setRequestHeader("Content-Type",
                                       "multipart/mixed; boundary=\"" +
                                       boundary + "\"");
//putMethod.setRequestHeader("Content-Disposition", "attachment;
filename=\"ral_031105.txt\"");
                         putMethod.setRequestHeader("Translate", "f");
                         putMethod.setRequestHeader("Saveinsent", "f");
//putMethod.setRequestHeader("Content-Type", "message/rfc821");

                         String sQuery = "--" + boundary + CRLF +
                            "Content-Type: message/rfc821" + CRLF + CRLF +
                            "MAIL FROM:<" + email.getFrom() + ">" + CRLF +
                            "RCPT TO:<" + email.getTo() + ">" + CRLF +
                            "RCPT TO:<" + email.getCc() + ">" + CRLF + CRLF
+
                            "Subject:" + email.getSubject() + CRLF + CRLF +
                            email.getBody() + CRLF + CRLF +
                            "--" + boundary + "--" + CRLF +
                            "Content-Type: text/plain" + CRLF +
             "Content-Disposition: attachment; filename=\"ral_031105.txt\""
+
                            CRLF + CRLF +
                            "Attachment text" + CRLF + CRLF;


            putMethod.setRequestEntity(new org.apache.commons.httpclient.
                                       methods.StringRequestEntity(sQuery));
            putMethod.addRequestHeader("Content-Length",
                                       new Integer(sQuery.length
()).toString());

Reply via email to