Outlook delete attachment files if use POP3

Hi every body,
I have a problem with outlook. I send a mail with attachment using java mail api. Anyone get the mail correctly (gmail, outlook, outlook express or thunderbird) via SMTP. But if outlook try to get the mail via POP3, it deletes attachment and show only other part of mail. Other clients dont do it include outlook express. I dont have any idea about this situation. Can any body help me?
My mail code is here:
Properties props = new Properties();
props.put("mail.smtp.host", server);
props.put("mail.smtp.port", String.valueOf(port));
session = Session.getDefaultInstance(props, null);
transport = session.getTransport("smtp");
     MimeMessage msg = new MimeMessage(session);
     msg.setSentDate(new Date());
     msg.setFrom(fromAddress);
     msg.setRecipients(Message.RecipientType.TO, toAddress);
     msg.setSubject(subject, "UTF-8");
     MimeBodyPart messageBodyPart = new MimeBodyPart();
     String htmlEncoded = TurkishLocaleHelper
               .convertTrToUTF8(message);
     messageBodyPart.setText(htmlEncoded);
     messageBodyPart.setHeader("Content-Type",
               "text/html;charset=UTF-8");
     messageBodyPart.setHeader("Content-Transfer-Encoding",
               "quoted-printable");
     MimeMultipart multipart = new MimeMultipart(
               "alternative");
     multipart.addBodyPart(messageBodyPart);
     if (mailItem.getAttachmentFileList() != null) {
          for (String fileName : mailItem.getAttachmentFileList()) {
               BodyPart fileBodyPart = new MimeBodyPart();
               DataSource source = new FileDataSource(fileName);
               fileBodyPart.setDataHandler(new DataHandler(source));
               fileBodyPart.setFileName(FileUtil.trimFilePath(fileName));
               multipart.addBodyPart(fileBodyPart);
     if (mailItem.getAttachmentFileMap() != null) {
          Map<String, String> fileMap = mailItem.getAttachmentFileMap();
          Set<String> keySet = fileMap.keySet();
          for (String filePath : keySet) {
               String fileName = fileMap.get(filePath);
               BodyPart fileBodyPart = new MimeBodyPart();
               DataSource source = new FileDataSource(filePath);
               fileBodyPart.setDataHandler(new DataHandler(source));
               fileBodyPart.setFileName(fileName);
               multipart.addBodyPart(fileBodyPart);
     msg.setContent(multipart);
     msg.saveChanges();
transport.sendMessage(msg, msg.getAllRecipients());Edited by: vistek on Apr 13, 2010 6:10 AM

Yes i was wrong. I use SMTP to sent mail, and POP3 to read it. Mail is shown with attachment in gmail but it is shown only body in outlook. If i open socket and sent mail via socket it is worked.
Now i search using this method with attachment. Does any body know that?
Example code:
import java.net.*;
import java.io.*;
public class SMTP {
  private String message;
  private String localMachine;
  private String senderName;
  private String recipient;
  private boolean valid_and_unsent = false;
  private BufferedReader in;
  private BufferedWriter out;
  // class constants
  public static final int SMTP_PORT = 25;
  private static final boolean logging = true;
  public SMTP() {
  public SMTP(String sender) {
    int indexOfAtSign = sender.indexOf('@');
    if (indexOfAtSign < 0) {
      throw new RuntimeException("Malformed sender address." +
        " Need full user@host format");
    this.senderName = sender.substring(0, indexOfAtSign);
    this.localMachine = sender.substring(indexOfAtSign + 1);
  public SMTP(String sender, String recipient, String message) {
    this(sender);
    setMessage(recipient, message);
  public void setMessage(String recipient, String message) {
    this.recipient = recipient;
    this.message = message;
    valid_and_unsent = true;
  public void send() throws IOException {
    if (!valid_and_unsent) {
      throw new RuntimeException("Attempt to send incomplete message," +
        " or send message twice");
    // if this message is legitimate, continue to extract
    // the remote machine name
    int indexOfAtSign = recipient.indexOf('@');
    if (indexOfAtSign < 0) {
      throw new RuntimeException("Malformed recipient address." +
        " Need full user@host format");
    String destinationMachine = recipient.substring(indexOfAtSign + 1);
    // attempt to make the connection, this might throw an exception
    Socket s = new Socket(destinationMachine, SMTP_PORT);
    in = new BufferedReader(
           new InputStreamReader(s.getInputStream(),"8859_1"));
    out = new BufferedWriter(
           new OutputStreamWriter(s.getOutputStream(),"8859_1"));
    String response;
    // discard signon message, introduce ourselves, and discard reply
    response = hear();
    say("HELO " + localMachine + "\n");
    response = hear();
    say("MAIL FROM: " + senderName + "\n");
    response = hear();
    say("RCPT TO: " + recipient + "\n");
    response = hear();
    say("DATA\n");
    response = hear();
    say(message + "\n.\n");
    response = hear();
    say("QUIT\n");
    // now close down the connection..
    s.close();
  private void say(String toSay) throws IOException {
    out.write(toSay);
    out.flush();
    if (logging) {
      System.out.println(toSay);
  private String hear() throws IOException {
    String inString = in.readLine();
    if ("23".indexOf(inString.charAt(0)) < 0) {
      throw new IOException("SMTP problem: " + inString);
    if (logging) {
      System.out.println(inString);
    return inString;
  public static void main(String args[]) throws Exception {
    BufferedReader in = new BufferedReader(
                               new InputStreamReader(System.in));
    System.out.print("Your address: ");
    System.out.flush();
    String sender = in.readLine();
    System.out.print("Recipient address: ");
    System.out.flush();
    String recipient = in.readLine();
    String message = "";
    String part;
    System.out.println("Message, end with '.' by itself:");
    for (;;) {
      part = in.readLine();
      if ((part == null) || part.equals(".")) {
        break;
      message += part + "\n";
    SMTP mailer = new SMTP(sender, recipient, message);
    mailer.send();
}

Similar Messages

  • ITunes Match has stopped uploading - every file errors and says waiting - I have tried to delete the files and use other formats etc.  I have had the service since Day 1 and NEVER had an issue.  It didn't start until the Delete from Cloud switch to Hide

    iTunes Match has stopped uploading - every file errors and says waiting - I have tried to delete the files and use other formats etc.  I have had the service since Day 1 and NEVER had an issue.  It didn't start until the Delete from Cloud switch to Hide from cloud - the files that do not upload show grayed out on my other devices.

    Have you confirmed that you successfull purged iTunes Match by also looking on an iOS device?  If so, keep in mind that Apple's servers may be experiencing a heavy load right now.  They just added about 19 countries to the service and I've read a few accounts this morning that suggests all's not running perfectly right now.

  • Can I attach file by using QA11 BAPI ?

    I want to make a list similar QA32.
    In that list, I will make usage decision by using BAPI.
    But I can't attach file by using BAPI.
    Can I attach file by using QA11 BAPI(BAPI_INSPLOT_GETDETAIL or  BAPI_INSPLOT_SETUSAGEDECISION) ?

    Try to use FM in BDC

  • Send mail with attached file without using Repository

    Hello,
    I want to know if have a way to Send mail with attached file without using Repository.
    Regards
    Elad

    Elad,
    Check this article where a image has been picked by the file adapter and sent as an attachment to the mail adapter.
    <a href="https://www.sdn.sap.comhttp://www.sdn.sap.comhttp://www.sdn.sap.com/irj/sdn/go/portal/prtroot/docs/library/uuid/6d967fbc-0a01-0010-4fb4-91c6d38c5816">Sending an Image File Through XI in a File-to-Mail Scenario</a>
    For how to proceed without integration repository content look into this blog,
    <a href="/people/william.li/blog/2006/09/08/how-to-send-any-data-even-binary-through-xi-without-using-the-integration-repository">How to send any data (even binary) through XI, without using the Integration Repository</a>
    Combining these 2 you have the solution.
    Regards
    Bhavesh

  • How to delete when file in use by the finder?

    I have two files in my trash which won't delete. I get the error that they are being used by another program. Holding down option, using secure empty trash, using the terminal method of deleting the trash.. none of them work.
    So I did the terminal command: lsof /path-to-file and found out it was being used by Finder. I don't think I can exactly quit the Finder process in Activity Monitor.. so how can I get these files out of my trash?

    Thanks. Unfortunately, when I quit finder and try to delete the files in the trash by the following command:
    sudo rm -rf ~/.Trash/*
    It tells me "Directory not empty". Argghh..
    I feel like I've tried everything. Can someone give me some other suggestions? Thanks

  • How to delete a file by using batch file

    hi
    i tried for deleting a file from batch filr in Linux environment.
    it is working when i run batch file thruogh command line.
    but its not woking through program.
    i am sending tha code that i used in tha program.
    First i have to create the file and send the information to that file
    and the content from taht file after that i have to delete the file.
    For that i wrote code but the batch is not woking.
    Batch file
    @echo off
    rm filename
    Actual Program Code
    I used RunServer
    public class RunServer extends Object
    RunServer();
    String cmdServer = "test.bat";
    Runtime run = Runtime.getRuntime();
    Process p = null;
    try
    p = run.exec(cmdServer);
    catch(IOException e)
    System.out.println("Error:"+e);
    By using RandomAccessFile i am creating a file
    please help me
    Thankyou

    1) You can't execute a batch without having a shell.
    2) It's totally stupid to run a one-line batch file from system.exec.
    3) It's also totally stupid to delete a file using Runtime altogether.
    But there you go...

  • Can't delete NAS files "in use"

    We have a Cisco NAS connected to our network of 10 macs. We work live on all projects across the network. Selected files and folders say they are in use when we try to trash them. Can anyone offer ideas? I need the 65GB these files are using!

    Shut down all clients, restart the NAS and then delete.

  • Problem in deleting Zip files unzipped using java.util.zip

    I have a static methos for unzipping a zip file. after unzipping the file when i am trying to delete that file using File.delete()its not getting deleted. but when methods like exist(). canRead(), canWrite() methods are returning true what can be the possible problem ? i had closed all the streams after unzipping operation Please go through the following code.
    public static boolean unzipZipFile(String dir_name, String zipFileName) {
    try {
    ZipFile zip = new ZipFile(zipFileName);
    Enumeration entries = zip.entries();
    while (entries.hasMoreElements()) {
    ZipEntry entry = (ZipEntry) entries.nextElement();
    // got all the zip entries here
    // now has to process all the files
    // first all directories
    // then all the files
    if (entry.isDirectory()) {
    // now the directories are created
    File buf=new File(dir_name,entry.getName());
    buf.mkdirs();
    continue;
    }// now got the dirs so process the files
    entries = zip.entries();
    while(entries.hasMoreElements()) {
    // now to process the files
    ZipEntry entry = (ZipEntry) entries.nextElement();
    if (!entry.isDirectory()){
    File buf=new File(dir_name,entry.getName());
    copyInputStream(
    zip.getInputStream(entry),
    new BufferedOutputStream(
    new FileOutputStream(buf)));}
    } catch (IOException e) {
    e.printStackTrace();
    return false;
    return true;
    now i am trying to call this method to unzip a zip file
    public static void main (String arg[]){
    unzipZipFile("C:/temp","C:/tmp.zip");
    java.io.File filer = new File("C:/tmp.zip");
    System.out.println (filer.canRead());
    System.out.println (filer.canWrite());
    System.out.println (filer.delete());
    Please tell me where my program is going wrong ?

    Thanks .. the problem is solved... i was not closing the Zip file .. rather i was trying to close all the other streams that i used for IO operaion ... thanks a lot

  • Mail leaves outgoing attachment files in use

    I've found that if I send a file as an attachment in an email, I can't delete that file until I quit Mail. It looks like Mail just forgets to close the file handle when it's done sending it.
    Has anyone else noticed this? Can it please be fixed in a future Mail release?

    AndrewB2009 wrote:
    I've found that if I send a file as an attachment in an email, I can't delete that file until I quit Mail. It looks like Mail just forgets to close the file handle when it's done sending it.
    Has anyone else noticed this? Can it please be fixed in a future Mail release?
    Welcome to Apple's discussion groups.
    I've noticed that. You might want to file a report in Apple's feedback area:
    http://www.apple.com/feedback/macosx.html

  • Cannot attach file when using mac mini (hotmail)

    when i use my mac mini desk top, i am not able to attach file to my mails when i am using hotmail.  i do not have the same problem using other computer, windows or other mac product.  so i know it is the problem of the mac mini.  i just started having this problem last couple of months, before that, everything was normal.  have i accidentally set something wrong or is there any way to fix it?  Please HELP! 

    What happens when you try?
    Are you dragging & dropping or using the file Menu?
    Could be many things, we should start with this...
    "Try Disk Utility
    1. Insert the Mac OS X Install disc, then restart the computer while holding the C key.
    2. When your computer finishes starting up from the disc, choose Disk Utility from the Installer menu at the top of the screen. (In Mac OS X 10.4 or later, you must select your language first.)
    Important: Do not click Continue in the first screen of the Installer. If you do, you must restart from the disc again to access Disk Utility.
    3. Click the First Aid tab.
    4. Select your Mac OS X volume.
    5. Click Repair. Disk Utility checks and repairs the disk."
    http://docs.info.apple.com/article.html?artnum=106214
    Then try a Safe Boot, (holding Shift key down at bootup), run Disk Utility in Applications>Utilities, then highlight your drive, click on Repair Permissions, reboot when it completes.
    (Safe boot may stay on the gray radian for a long time, let it go, it's trying to repair the Hard Drive.)

  • I have a galaxy 3 phone and i think i may have deleted some files it used on my home pc...i can no longer sink it with my computer.. please help

    i recently deleted some files from my compter and now my phone, a Galaxy 3 will no longer sink with my home pc...Please help

        Hello BCoufalik
    Let's see if we can get that galaxy S3 connected with your PC. Here's a great link that will help with Syncing: http://search.verizonwireless.com/?q=sync galaxy s3 &x1=p1&q1=support
    JoeL_VZW
    Follow us on Twitter @VZWSupport

  • How to delete audio files if using manual update

    hi,
    i have my iPod set for manual updating and i just realized that when i delete songs using iTunes the actual files stay on the iPod, wasting disc space. how can i delete those to free up more disc space (other than searching for each song and deleting it manually every time)? i will start using automatic updating evenutally but for now i am stuck with manual updating.
    thanks in advance...

    Under the "manually manage songs" setting, you should be able to click the little arrow next to your iPod in iTunes. Then, if you want to get rid of a song on your iPod, just select it, and hit backspace. I don't know why this wouldn't work, but it worked with my iPod.

  • Reinstalling CS4 after deleting the files without using the uninstaller

    Hi I didn't know that I have to use the uninstaller to uninstall my adobe CS4 products on my mac. My photoshop was giving me problems and I decided to reinstall it. However, I uninstalled it the normal mac way i.e. simply deleting it. Now I'm having trouble reinstalling as the installer always fails. Any way to resolve this?
    Thanks!

    However, I uninstalled it the normal mac way i.e. simply deleting it.
    That hasn't been "the normal Mac way" for the last decade... Run the Creative Suite Cleaner Tool, reinstall.
    Mylenium

  • Can't delete old files from used TC

    I bought a 500GB time capsule on ebay. No problem with the wireless, but I can't do a back up because it looks like the files from the old user are still on there.

    kbug61 wrote:
    I bought a 500GB time capsule on ebay. No problem with the wireless, but I can't do a back up because it looks like the files from the old user are still on there.
    Launch AirPort Utility, double-click on your Time Capsule to enter "Manual Setup" mode, select the "Disks" icon in the toolbar, select "Time Capsule Disk" (or whatever yours is called) on the left, then click the "Erase" button.

  • Delete specific attachment file through Conversion Channel ?

    version : iMS5.2 sp1
    O/S : Solaris 2.6 Generic_105181-29
    I wanted to delete specific attachment file(ex: ALTDESK.ZIP) through Conversion Channel.
    So I set up like below..
    1) In mappings file
    =================
    CONVERSIONS
    IN-CHAN=tcp_intranet;OUT-CHAN=tcp_local;CONVERT Yes
    ==============
    I only want to delete attached file from tcp_intranet to tcp_local.
    2) msg-INSTANCE/imta/config/conversions
    example mail header ::
    --- omit ----
    MIME-version: 1.0
    X-Mailer: iPlanet Messenger Express 5.2 Patch 1 (built Aug 19 2002)
    Content-type: multipart/mixed; boundary=--6b2385053506b85
    Content-language: ko
    X-Accept-Language: ko
    Priority: normal
    This is a multi-part message in MIME format.
    ----6b2385053506b85
    Content-Type: text/plain; charset=EUC-KR
    Content-Disposition: inline
    Content-Transfer-Encoding: quoted-printable
    ----6b2385053506b85
    Content-Type: application/x-zip-compressed
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment; filename=ALTDESK.ZIP
    - conversions file setting
    ==================================================
    in-channel=tcp_intranet; out-channel=tcp_local;
    in-type=application; in-subtype=x-zip-compressed;
    parameter-symbol-0=ALTDESK.ZIP; parameter-copy-0=*;
    dparameter-symbol-0=ALTDESK.ZIP; dparameter-copy-0=*;
    message-header-file=2; original-header-file=1;
    override-header-file=1; override-option-file=1;
    command="/product/leeky/convert.sh"
    ============================================
    3) /product/leeky/convert.sh file
    ========================
    #!/bin/sh
    if [ $? -eq 1 ]; then
    echo "STATUS=178030178" >> $OUTPUT_OPTIONS
    else
    cp $INPUT_FILE $OUTPUT_FILE
    fi
    =========================
    4) The problems I face are
    - All of zip files which are filtered is deleted. As you can see 2) I only want to delete ALTDESK.ZIP file
    But, all of the zip-compressed files are deleted at the moment.
    - This converison channel is work(even if all zip-compressed files are deleted). But sometimes this is not
    working(2 or 3 times out of 10). I don not know why.
    - Above all, I am not sure 2) and 3) settings are good. English is a second language to me. So it was
    not easy to understand conversion channel setting in Admin Guide.
    - How can I see the out put of "$OUTPUT_OPTIONS" ? I do not know where I can see that.
    Is there anybody to help me ?

    The section of the admin guide which can help is:
    http://docs.sun.com/source/816-6009-10/channel2.htm#42283
    Here there is an explanation of how the mime headers of the message part would align with the entries one would put into the conversions file entry. (The document has an error where it talks about APPARENT_NAME and APPARENT_FILENAME. It should really say the words "NAME" and "FILENAME" respectively).
    Based on that document, the MIME headers of your message part :
    Content-Type: application/x-zip-compressed
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment; filename=ALTDESK.ZIP
    will align with a conversions file settiong of:
    in-channel=tcp_intranet; out-channel=tcp_local;
    in-type=application; in-subtype=x-zip-compressed;
    parameter-symbol-0=NAME; parameter-copy-0=*;
    dparameter-symbol-0=FILENAME; dparameter-copy-0=*;
    message-header-file=2; original-header-file=1;
    override-header-file=1; override-option-file=1;
    command="/product/leeky/convert.sh"
    and a /product/leeky/convert.sh script which reads something like:
    #!/bin/sh
    grep "$FILENAME" /product/leek/badfiles.list
    if [ $? -eq 1 ]; then
    echo "STATUS=178030178" >> $OUTPUT_OPTIONS
    else
    grep "$NAME" /product/leek/badfiles.list
    if [ $? -eq 1 ]; then
    echo "STATUS=178030178" >> $OUTPUT_OPTIONS
    else
    cp $INPUT_FILE $OUTPUT_FILE
    fi
    fi
    The lines:
    parameter-symbol-0=NAME; parameter-copy-0=*;
    dparameter-symbol-0=FILENAME; dparameter-copy-0=*;
    tells the conversion channel to make the environment variable $NAME avaliable to your program with a value corresponding to the "name=" clause on the Content-Type line of the MIME headers. The environment variable $FILENAME is made avalable to your program and takes on the value extracted from the filename=" clause on the content-disposition line of the MIME headers.
    The document at :
    http://docs.sun.com/source/816-6092-10/conversion.html
    may help provide other examples.

Maybe you are looking for