Adding attachments w/email

I used the (http://developer.java.sun.com/developer/onlineTraining/JavaMail/exercises/MailAttach/index.html) as a guide to add attachments to my email sender util when necessary... except when I add the attachment it just shows up below the email body I entered, not as a word attachment. I've attached my code below... Thanks for any help.
private MimeMessage createMimeMessage(Session session, String from,
String[] to, String subject, String body, String fileAttachment)
throws MessagingException {
MimeMessage message = new MimeMessage(session);
InternetAddress fromAddress = null;
fromAddress = new InternetAddress(from);
message.setFrom(fromAddress);
InternetAddress[] toAddresses = new InternetAddress[to.length];
for(int i=0; i<to.length; i++) {
toAddresses[i] = new InternetAddress(to);
message.addRecipients(Message.RecipientType.TO, toAddresses);
message.setSubject(subject);
          MimeBodyPart messageBodyPart = new MimeBodyPart();
          messageBodyPart.setText(body);
          Multipart mp = new MimeMultipart();
          mp.addBodyPart(messageBodyPart);
          String fileName = fileAttachment;
          if(!"null".equals(fileAttachment) && fileAttachment != null) {
               fileAttachment = ConfigProperties.getFilePath() + fileAttachment;
          if(!"null".equals(fileAttachment) && fileAttachment != null) {
               MimeBodyPart messageBodyPart2 = new MimeBodyPart();
               // attach the file to the message
               FileDataSource fds = new FileDataSource(fileAttachment);
               messageBodyPart2.setDataHandler(new DataHandler(fds));
               messageBodyPart2.setFileName(fileName);
               // create the Multipart
               //and its parts to it
               mp.addBodyPart(messageBodyPart2);
          message.setContent(mp);
return message;

Heres the class I use to send attachments:
http://www.discoverteenergy.com/files/EMail.java

Similar Messages

  • Adding Attachments to emails

    I need to send out personalized emails with an attachment to a list of people. I found an automator script that will take care of building and personalizing each email, but is there an automator script that will add attachments as well?
    It looks like the "add attachment" command should work, but I need to specify the file in a previous step, and I can't figure out what action I need to use for that.

    Use the +Get Selected Finder Item+ or the +Get Specific Finder Item+.

  • Saving added attachments in emails

    Can anybody tell me how to save these attachments on internal/added memory?

    This feature in not available in BlackBerry device. Probably in future releases this might be addressed by RIM considering the user demands.
    tanzim                                                                                  
    If your query is resolved then please click on “Accept as Solution”
    Click on the LIKE on the bottom right if the post deserves credit

  • Adding Attachments To eMail?

    Goal is to respond to Craig's List job ads via email. Need to compose a message containing: a) the coded email response address in the To field, b) text responding to the specific ad, and c) a PDF of a resume. The PDF currently exists only as an attachement in an email from a Mac.
    I have been struggling with this. Two problems:
    1. Difficulty copying / pasting the coded email address into the "To" field in Mail.
    2. Attaching the resume as a PDF
    Anyone know how to do this?
    Thanks,

    Go back to your original mail attachment post from eight days' earlier:
    Attaching pdf to demo_mail
    Continue there instead of just abandoning it.
    +.. locking...+

  • Trouble adding attachments to email in web version

    I am trying to attach small files (500k) to an email in the web version but it never uploads.  This happens often.
    It's not the attachment or my connection because it attaches right away with gmail or yahoo accts.
    I haven't yet upgraded to lion or mountain lion.  But that shouldn't matter with the web version, right?
    Is anyone else having this trouble?
    Mike

    @Ruslim Chang 
       Sorry to point out but the FM will return the Workitem ID only so there is no problem with the LV_WF_ID variable.
    @vundralla nagaraju
    Instead of making binding between attachobjects make binding between
    WiGroup_ID <---- attachobjects
    and then on the next step you try to make biniding in the user decision step by using WiGroup_ID.I think it should work.

  • Adding attachments causes email application (Safari or Firefox) to crash.

    This is a recent condition, after years of using the machine and software. If I move the attachment file to my PowerBook G4 1.33mHz, I have no trouble. Appears to be something in the hardware. Any ideas will be greatly appreciated.

    Which web based mail service do you use? Have you run routine maintenance? Are you dragging and dropping, searching for an attachment, sending form iPhoto? Any particular types of attachments? How large?

  • Can you customize what folder MAIL goes to when adding attachments?

    Can you customize what folder MAIL goes to when adding attachments?
    My friend has 2 email addresses for businesses.
    He has invoices in folders for both, and wants to set up the Mac like this:
    When he writes from one email address and attaches documents - he want the Mac always to go to the corresponding folder for that company of his. Same for the other email address...
    Make sense?
    Can this be done?
    Thanks in advance....

    Please read this whole message before doing anything.
    This procedure is a diagnostic test. It’s unlikely to solve your problem. Don’t be disappointed when you find that nothing has changed after you complete it.
    The purpose of the test is to determine whether your problem is caused by third-party system modifications that load automatically at startup or login. 
    Disconnect all wired peripherals except those needed for the test, and remove all aftermarket expansion cards. Boot in safe mode* and log in to the account with the problem. The instructions provided by Apple are as follows:
    Shut down your computer, wait 30 seconds, and then hold down the shift key while pressing the power button.
    When you see the gray Apple logo, release the shift key.
    If you are prompted to log in, type your password, and then hold down the shift key again as you click  Log in.
    *Note: If FileVault is enabled under OS X 10.7 or later, or if a firmware password is set, or if the boot volume is a software RAID, you can’t boot in safe mode. Safe mode is much slower to boot and run than normal, and some things won’t work at all, including wireless networking on certain Macs.  The next normal boot may also be somewhat slow.
    The login screen appears even if you usually log in automatically. You must know your login password in order to log in. If you’ve forgotten the password, you will need to reset it before you begin. Test while in safe mode. Same problem? After testing, reboot as usual (i.e., not in safe mode) and verify that you still have the problem. Post the results of the test.

  • PDFmaker not converting Jpg attachments to emails in Microsoft Outlook 2013

    I am having problems converting jpg attachments to emails in Microsoft Outlook 2013 using PDFmaker. I'm running Adobe Acrobat 11 and just updated it to the latest version and that did not solve the problem.
    I can convert the emails and Word attachments and can convert the jpgs manually by saving them to my desk top and then adding them as attachments to the resulting PDF but I have several emails each was several attachments that I want to save and it will take me hours to do it manually.
    I was thinking there might be some security setting on the jpgs that is preventing PDFmaker from automatically converting them.
    I already confirmed that the Preference Conversion Setting is selected to include all attachments in the Adobe PDF. I also unselected the box that reads "block download of external content" but it did not help.

    Manual method is a difficult task .You can easily transfer your mails from the Thunderbird to MS Outlook using third party conversion software.i faced the same problem.i tried the following utility. It converts all my Thunderbird accounts to a single PST.you can also try the free demo version of the software.
    http://www.datacarelab.com/software-for-mbox-to-outlook.php

  • Sending attachments with emails in Javamail

    I'm trying to send attachments with emails using Javamail. Following is the code through which I'm trying to achieve that. It works as expected on a JRE1.6 environment. But on JRE1.5, the content of the file gets added to the mail body as text.I want the file to be sent as an attachment.
    Any pointers on the observed difference in behavior would be highly appreciated!
    String msgText = mailInfo.getMessage();
            String attachmentFileName = mailInfo.getFileName();
            MimeBodyPart mimeBodyPart = new MimeBodyPart();
            mimeBodyPart.setText(msgText);
            // create the second message part
            MimeBodyPart attachmentBodyPart = new MimeBodyPart();
            // attach the file to the message
            FileDataSource fileDataSource = new FileDataSource(attachmentFileName);
            attachmentBodyPart.setFileName(fileDataSource.getName());
            attachmentBodyPart.setDataHandler(new DataHandler(fileDataSource));
            // create the Multipart and add its parts to it
            Multipart multipart = new MimeMultipart();
            multipart.addBodyPart(mimeBodyPart);
            multipart.addBodyPart(attachmentBodyPart);
            message.setContent(multipart);The email in case of JRE1.5 is as follows
    {color:#0000ff}------=_Part_0_33189144.1233078680250
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    Hi...Test Mail
    ------=_Part_0_33189144.1233078680250
    Content-Type: application/octet-stream; name=corba_architecture.pdf
    Content-Transfer-Encoding: base64
    Content-Disposition: attachment; filename=corba_architecture.pdf
    Content-ID: Attachment
    JVBERi0xLjIgDSXi48/TDQogDTggMCBvYmoNPDwNL0xlbmd0aCA5IDAgUg0vRmlsdGVyIC9GbGF0
    ZURlY29kZSANPj4Nc3RyZWFtDQpIiUWPW07DMBBFV+A93E9QlWBP/Kj5awt8USFRbyBKnTQIkshK
    YfvYcQoaybrSzDkzFhCxQgemeWkUyKTXEIeSHMGjZXvHSFBJCpXUpQLcE+NIlbCHFw4pUxeuZQUv
    ueY25gYxk9mKmH9wtwvNpZ99M1+jc2wxXzxweHvf73AP9xGFhaIsTyC3/w6ZDYfxaxoHP8w4jmf/
    ------=_Part_0_33189144.1233078680250-- {color}

    Following is the debug trace obtained on running the program on 1.5.
    +12:45:57,218 INFO [MailerThread] EmailManager:306 - Sending message {toAddress [email protected],+
    +replyTo =null,+
    +cc =null,+
    +message =Hi...Test Mail,+
    +subject =test mail,+
    +contentType =null fileName =C:\docs\cbe\dist computing\A.txt }+
    Loading javamail.default.providers from jar:file:/C:/docs/cbe/lib/mail-1.4.jar!/META-INF/javamail.default.providers
    DEBUG: loading new provider protocol=imap, className=com.sun.mail.imap.IMAPStore, vendor=Sun Microsystems, Inc, version=null
    DEBUG: loading new provider protocol=imaps, className=com.sun.mail.imap.IMAPSSLStore, vendor=Sun Microsystems, Inc, version=null
    DEBUG: loading new provider protocol=smtp, className=com.sun.mail.smtp.SMTPTransport, vendor=Sun Microsystems, Inc, version=null
    DEBUG: loading new provider protocol=smtps, className=com.sun.mail.smtp.SMTPSSLTransport, vendor=Sun Microsystems, Inc, version=null
    DEBUG: loading new provider protocol=pop3, className=com.sun.mail.pop3.POP3Store, vendor=Sun Microsystems, Inc, version=null
    DEBUG: loading new provider protocol=pop3s, className=com.sun.mail.pop3.POP3SSLStore, vendor=Sun Microsystems, Inc, version=null
    DEBUG: getProvider() returning provider protocol=smtp; type=javax.mail.Provider$Type@77eaf8; class=com.sun.mail.smtp.SMTPTransport; vendor=Sun Microsystems, Inc
    DEBUG SMTP: useEhlo true, useAuth false
    DEBUG SMTP: trying to connect to host "10.16.68.131", port 25, isSSL false
    +220 mailhost5.vmware.com ESMTP Postfix (mailhost5)+
    DEBUG SMTP: connected to host "10.16.68.131", port: 25
    EHLO sbanerjee
    +250-mailhost5.vmware.com+
    +250-PIPELINING+
    +250-SIZE 26800000+
    +250-VRFY+
    +250-ETRN+
    +250-ENHANCEDSTATUSCODES+
    +250-8BITMIME+
    +250 DSN+
    DEBUG SMTP: Found extension "PIPELINING", arg ""
    DEBUG SMTP: Found extension "SIZE", arg "26800000"
    DEBUG SMTP: Found extension "VRFY", arg ""
    DEBUG SMTP: Found extension "ETRN", arg ""
    DEBUG SMTP: Found extension "ENHANCEDSTATUSCODES", arg ""
    DEBUG SMTP: Found extension "8BITMIME", arg ""
    DEBUG SMTP: Found extension "DSN", arg ""
    DEBUG SMTP: use8bit false
    MAIL FROM:<[email protected]>
    +250 2.1.0 Ok+
    RCPT TO:<[email protected]>
    +250 2.1.5 Ok+
    DEBUG SMTP: Verified Addresses
    DEBUG SMTP:   [email protected]
    DATA
    +354 End data with <CR><LF>.<CR><LF>+
    ------=_Part_0_3278348.1233126957281
    Content-Type: text/plain; charset=us-ascii
    Content-Transfer-Encoding: 7bit
    Hi...Test Mail
    ------=_Part_0_3278348.1233126957281
    Content-Type: text/plain; charset=us-ascii; name=A.txt
    Content-Transfer-Encoding: 7bit
    Content-Disposition: attachment; filename=A.txt
    Content-ID: Attachment
    adasdasdd
    ------=_Part_0_3278348.1233126957281--
    +.+
    +250 2.0.0 Ok: queued as 5BE5BDC100+
    +12:45:59,125 INFO [MailerThread] EmailManager:331 - Message {toAddress [email protected],+
    +replyTo =null,+
    +cc =null,+
    +message =Hi...Test Mail,+
    +subject =test mail,+
    +contentType =null fileName =C:\docs\cbe\dist computing\A.txt } sent to the SMTP server successfully+

  • I can't get my ICloud started. Each time i try to sign in..it indicates that theres a problem with my email apple address but never indicates what. I added a second email but the same result. Have changed my password numerous times...no result?????

    I have followed the instruction relating to Icloud connection.When i went to system preferences, my Apple address is continually rejected. I have added a second email as suggusted by an Apple site but i still get the same message. Im not told why the Apple ID/email is not accepted when it is accepted in all other Apple sites. I changed my password numerous times to ensure it wasnt the password but to no result. It continued to state that my Apple ID was the problem. I live in Malta,Europe. Have new Apple Mac Pro and Ipod. The annoying thing is that ICloud continually send me the problem notice but do nothing to tell me how to fix it? Can i switch this notice off? Help???????

    Welcome to the Apple community Yao.
    If you mean that Find My Phone is asking for a password to a different Apple ID to your current Apple ID.
    This feature has been introduced to make stolen phones useless to those that have stolen them.
    However it can also arise when the user has changed their Apple ID details with Apple and not made the same changes to their iCloud account/Find My Phone on their device before upgrading to iOS 7, or if you restore from a previous back up made before you changed your details.
    The only solution is to change your Apple ID back to its previous state with Apple at My Apple ID using your current password, you don’t need access to this address if it’s previously been used with your Apple ID, once you have saved these details enter the password as requested on your device and then turn off "find my phone" and delete the account from your device.
    You should then change your Apple ID back to its current state, save it once again and then log back in using your current Apple ID. Finally, turn "find my phone" back on once again.
    This article provides more information about Activation Lock.

  • Multiple apple IDs.  Considering adding an icloud email address.

    I've had my apple ID, which is my name, for MANY years.  At some point, I was forced to change my apple ID to an email address.  I changed it to a yahoo.com address, an email address I've had for ages.  Now I have 2 apple IDs.  When I do updates on my computer I often have to log into both because some programs were originally installed with my name only ID, and others later with my yahoo account ID. 
    I've always been confused about Icloud, because I cannot access all of the features because I don't have an @icloud, @mac, or @me email address.  I'm considering adding an icloud email address, but am afraid of what the consequences might be.  I have a completely different email address that I use for all of my regular email.
    Will my name only apple ID change to [email protected]?
    Will the apps that I originally downloaded with the nameonly ID know this? 
    What will happen on my ipad and iphone5? 
    will i need to set up another email account on my iphone so that my pictures will stream to photos?
    Thanks for your help
    Todd.

    You can create an iCloud account using your existing Yahoo.com ID rather than creating a new ID.  (You can use the other one because it has to be in the form of an email address and linked to a verifiable email account.)  To do this you would go to System Preferences>iCloud and sign in with the ID to create the account, then check the data you want to sync with iCloud.  When you check Mail, you will be prompted to create your @icloud.com email address.  This is the email account that goes with your iCloud account, if you wish to use iCloud email.  When you type the name you would like to use for this address, iCloud will search and tell you if it's already taken by someone else, in which case you will have to choose another.  Type carefully, as once created, your @icloud.com address cannot be changed.  Understand that your iCloud account ID will still be your @yahoo.com address.  The @icloud.com address you choose is for email only.
    None of this will effect your existing purchased media using your two Apple IDs.  These will stay the same as purchases are permanently tied to the ID used to purchase them.  Also, Apple will not merge IDs.

  • How can I get a search bar added to my email archives screen to make it easier to search for the right archives folder, Samsung has one so I was surprised to see that I have to scroll up and down to find the right folder?

    How can I get a search bar added to my email archives screen to make it easier to search for the right archives folder, Samsung has one so I was surprised to see that I have to scroll up and down to find the right folder?

    Start Firefox in <u>[[Safe Mode]]</u> to check if one of the extensions is causing the problem (switch to the DEFAULT theme: Firefox (Tools) > Add-ons > Appearance/Themes).
    * Don't make any changes on the Safe mode start window.
    * https://support.mozilla.com/kb/Safe+Mode
    * https://support.mozilla.com/kb/Troubleshooting+extensions+and+themes
    You can modify the pref <b>keyword.URL</b> on the <b>about:config</b> page to use Google's "I'm Feeling Lucky" or Google's "Browse By Name".
    * Google "I'm Feeling Lucky": http://www.google.com/search?btnI=I%27m+Feeling+Lucky&ie=UTF-8&oe=UTF-8&q=
    * Google "Browse by Name": http://www.google.com/search?ie=UTF-8&sourceid=navclient&gfns=1&q=
    * http://kb.mozillazine.org/keyword.URL
    * http://kb.mozillazine.org/Location_Bar_search

  • HT4191 how do I not sync notes with my email? I have a business email on my iphone as well as his iphone. Now all of my notes are on his phone, and all of his notes are gone. We have never adjusted any settings, I only added the shared email account to hi

    How do I not sync notes with my email? I have a business email on my iphone as well as my husbands iphone. Now all of my notes are on his phone, and all of his notes he previously has on his iphone are gone. We have never adjusted any settings or hooked it up to itunes, I only added the shared email account to his phone. Help???

    Hi StoneLeadyFarms,
    Thanks for visiting Apple Support Communities.
    It sounds like notes on your devices may have synced when the email account was added, as described here:
    iOS: Syncing Notes
    http://support.apple.com/kb/HT4191
    Notes are associated with an IMAP email account or iCloud account. To sync Notes, enable Notes for each account in Settings > Mail, Contacts, Calendars or Settings > iCloud.
    You can stop syncing notes by tapping Settings > Mail, Contacts, Calendars or Settings > iCloud, tapping the email address that you added, and switching Notes to the off position.
    Additionally, if your husband has backed up his iPhone to iTunes or iCloud, the steps in this article can help with recovering the lost notes from his device:
    iOS: Back up and restore your iOS device with iCloud or iTunes
    http://support.apple.com/kb/HT1766
    Best Regards,
    Jeremy

  • How do I send attachments in email as an icon

    How do I send attachments in email as an icon

    I mean when I have dropped a photo into the email how do I then change that to an icon so that other non Mac users can see it easier

  • How do I open attachments in emails I have received?

    How do I open attachments in emails I receive to view them before I send them on to friends?

    Often, pictures or simple documents (eg, one-page PDFs) will appear directly within the message itself. You can also use the Quick Look button next to the attachments line (in the message header) to view and scroll through the files (provided they're viewable, and aren't compressed or binary files).
    You can also click Save next to Quick Look to save the files to your Downloads folder.
    Matt

Maybe you are looking for

  • Applied Status is "NO" in v$archived_log in 11.2.0.2 Data Guard

    Hi Friends, I am using 11.2.0.2 Data Guard . I could perform Log Switch multiple times on Primary and the new sequence is getting reflected in Standby and the Archived Logs are also creating but i could see that in the v$archived_log the applied stat

  • Date offset as input on query selection screen

    Alright all, I have a date variable which is based on current month/year.  We need to allow the user the ability to offset this date by a month.  e.g. if date is 06.2010, they will have the ability to enter '2' as the offset and this will give them d

  • Apple TV loses purchased content

    My aTV has been losing purchased content - and this is the 2nd time that about five purchased movies (out of twenty) suddenly disappeared. While the ATV was paired with a laptop, I have not synced it for a few months as iTunes stopped showing the aTV

  • Strange wake-up; what just happened?

    Last night, as usual, I stored my MBP asleep and went to work.  When I came home, I opened it up, and nothing happened.  I noticed that the small light on the edge of the laptop was not on.  I tried the start button; I then got a grey screen with a s

  • Cannot delete payment proposal....... urgent

    Hi All, Today one of my user had aproblem with payment run, she was able to create payment proposal but when she did payment run it was cancelled When i checked payment log its due to the missing clearing document (bcoz mistakenly the clearing doc nu