Problem Sending attachments with JavaMail API

Hi,
I am able to succesfully able to send the attachment but the body message is not going with it. If i dont send the attachment then the email body goes properly. i can't understand what the problem is . please help.
import java.util.*;
import java.io.*;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
import com.sun.mail.smtp.SMTPMessage;
public class Emailer
     String emailSubject = null;
     String emailBody = null;
    String smtphost = null;
     String ccAddr = null;
     String file = "C:\\trainee\\eclipse_lg.gif";
     Vector vecToAddr = null;
     Vector vecCCAddr = null;
     Address fromAddr = null;
  public Emailer(Hashtable hashConfigParam) throws Exception
        smtphost = (String)hashConfigParam.get("host");
        ccAddr = (String)hashConfigParam.get("ccAddr");
        vecToAddr = new Vector();
        vecCCAddr = new Vector();
  public Boolean setFromAddr(String fromEmailAddr)
          try
               fromAddr = new InternetAddress (fromEmailAddr);
               //if(true)
               //throw new IOException();
          catch (Exception e)
               return null;
     return new Boolean(true);
  public Boolean setToAddr(String toEmailAddr)
          try
               for(int j=0; j< vecToAddr.size();j++)
                    if(((String)vecToAddr.get(j)).equals(toEmailAddr))
                         return new Boolean(false);
               vecToAddr.add(toEmailAddr);
               //if(true)
               //throw new IOException();
          catch (Exception e)
               return null;
               return new Boolean(true);     
     public Boolean setCCAddr(String ccEmailAddr)
          try
               for(int j=0; j< vecCCAddr.size();j++)
                    if(((String)vecCCAddr.get(j)).equals(ccEmailAddr) && ((String)vecCCAddr.get(j)).equals(ccAddr))
                         return new Boolean(false);
               vecCCAddr.add(ccEmailAddr);
               vecCCAddr.add(ccAddr);
               //if(true)
               //throw new IOException();
          catch (Exception e)
               //System.out.println(e.getClass().getName());
               return null;
          return new Boolean(true);               
     public Boolean setEmailSubject(String subject)
          try
               emailSubject = subject;
               if(emailSubject.equals(null))
                    return new Boolean(false);
               else
                    return new Boolean(true);
          catch (Exception e)
               return null;
          //return new Boolean(false);
     public Boolean setEmailBody(String body)
          try
               emailBody = body;
               if(emailBody.equals(""))
                    return new Boolean(false);
               else
                    return new Boolean(true);
          catch (Exception e)
               return null;
          //return new Boolean(false);
  public void sendEmail()
       try
            Properties eMailConfigProps = null;
            eMailConfigProps = System.getProperties();
            eMailConfigProps.put("mail.smtp.host", smtphost);
            Session session = Session.getInstance(eMailConfigProps, null);
            MimeMessage message = new MimeMessage(session);
               try
                 message.setFrom(fromAddr);
                  for(int i=0; i< vecToAddr.size(); i++)
                     message.addRecipient(Message.RecipientType.TO,new InternetAddress((String)vecToAddr.get(i)));
                     for(int i=0; i< vecCCAddr.size(); i++)
                      message.addRecipient(Message.RecipientType.CC,new InternetAddress((String)vecCCAddr.get(i)));
                  message.setSubject(emailSubject);
                  //message.setText(emailBody);
                   BodyPart messageBodyPart = new MimeBodyPart();
                    messageBodyPart.setText(emailBody);
                    Multipart multipart = new MimeMultipart();
                    DataSource source = new FileDataSource(file);
                    messageBodyPart.setDataHandler(new DataHandler(source));
                    messageBodyPart.setFileName(file);
                    multipart.addBodyPart(messageBodyPart);
                    message.setContent(multipart);
                    Transport.send(message);
               catch (SendFailedException ex)
                 ex.printStackTrace();
               catch (MessagingException ex)
                 System.err.println("Exception. " + ex);
       catch (Exception e)
            System.out.println(e.toString());
public static void main(String args[])
      Hashtable hash = new Hashtable();
      hash.put("host","213.312.230.211");
      hash.put("ccAddr","[email protected]");
     try
           Emailer objEmailer = new Emailer(hash);
          Boolean fromFlag = objEmailer.setFromAddr("[email protected]");
          String toAddresses = "[email protected]";
          String ccAddresses = "[email protected]";
          Boolean toFlag = objEmailer.setToAddr(toAddresses);
          Boolean ccFlag = objEmailer.setCCAddr(ccAddresses);
          Boolean subjectFlag  = objEmailer.setEmailSubject("Emailer.java");
          Boolean bodyFlag = objEmailer.setEmailBody("blah blah blahblha ");
          if((fromFlag.toString()).equals("true") && (toFlag.toString()).equals("true") && (bodyFlag.toString()).equals("true"))
               objEmailer.sendEmail();
     catch(AddressException e)
          e.printStackTrace();
     catch(Exception e)
          e.printStackTrace();

i.e example :
u can do it in this way
MimeBodyPart messageBody = new MimeBodyPart();
messageBody.setText("your message body goes here");
// attaching file i.e make separate object of body part
MimeBodyPart messageBodyPart = new MimeBodyPart();
DataSource source = new FileDataSource(filePath);
messageBodyPart.setDataHandler(new DataHandler(source));
messageBodyPart.setFileName(fileName);
multipart.addBodyPart(messageBody);
multipart.addBodyPart(messageBodyPart);
mimemessage.setContent(multipart);
Transport.send(mimemessage);

Similar Messages

  • Sending Attachments with JavaMail API

    I have an application where I need to develop a simple e-mail servlet where, from an HTML form, clients can enter their return email address and attach a file and send it to me. The jGuru short course said that when trying to send attachments via a servlet, the user must upload the attachment with the encoding type "multipart/form-data". If I remove the "enctype=multipart/form-data" statement, I can successfully send an email without an attachment. But when I add the statement, the servlet fails. Here is the HTML that I have been using, without success:
    <form enctype="multipart/form-data" action="../servlets/TestEmail" method="post">
    From: <input type="text" name="from" value=""><br>
    Subject: <input type="text" name="subject" value=""><br>
    File to Attach: <input type="file" name="filename"><br>
    Message: <textarea name="message"></textarea><br><br>
    <input type="submit" value="Send">
    </form>
    Can anyone show me the error of my ways?
    Many thanks.
    Chris

    Hi,
    You'll need to use the servlet attachment jar from http://www.servlet.com in your webserver library. Check out the site, it'll tell you what to do.
    I've also done an example servlet at http://www.salniere.com/WebTests/ServletMail which you can download and check out.
    good luck
    Kevin

  • Sending Attachments using JavaMail

    I trying to send attachments using JavaMail API which is loaded into an oracle 8.1.7 database as a stored procedure, the code looks like this:-
    CREATE OR REPLACE AND COMPILE JAVA SOURCE NAMED "SendMail" AS
    import java.util.*;
    import java.io.*;
    import javax.mail.*;
    import javax.mail.internet.*;
    import javax.activation.*;
    public class SendMail {
    // Sender, Recipient, CCRecipient, and BccRecipient are comma-
    // separated lists of addresses;
    // Body can span multiple CR/LF-separated lines;
    // Attachments is a ///-separated list of file names;
    public static int Send(String SMTPServer,
    String Sender,
    String Recipient,
    String CcRecipient,
    String BccRecipient,
    String Subject,
    String Body,
    String ErrorMessage[],
    String Attachments) {
    // Error status;
    int ErrorStatus = 0;
    // create some properties and get the default Session;
    Properties props = System.getProperties();
    props.put("mail.smtp.host", SMTPServer);
    Session session = Session.getDefaultInstance(props, null);
    try {
    // create a message;
    MimeMessage msg = new MimeMessage(session);
    // extracts the senders and adds them to the message;
    // Sender is a comma-separated list of e-mail addresses as
    // per RFC822;
    InternetAddress[] TheAddresses =
    InternetAddress.parse(Sender);
    msg.addFrom(TheAddresses);
    // extract the recipients and assign them to the message;
    // Recipient is a comma-separated list of e-mail addresses
    // as per RFC822;
    InternetAddress[] TheAddresses =
    InternetAddress.parse(Recipient);
    msg.addRecipients(Message.RecipientType.TO,
    TheAddresses);
    // extract the Cc-recipients and assign them to the
    // message;
    // CcRecipient is a comma-separated list of e-mail
    // addresses as per RFC822;
    if (null != CcRecipient) {
    InternetAddress[] TheAddresses =
    InternetAddress.parse(CcRecipient);
    msg.addRecipients(Message.RecipientType.CC,
    TheAddresses);
    // extract the Bcc-recipients and assign them to the
    // message;
    // BccRecipient is a comma-separated list of e-mail
    // addresses as per RFC822;
    if (null != BccRecipient) {
    InternetAddress[] TheAddresses =
    InternetAddress.parse(BccRecipient);
    msg.addRecipients(Message.RecipientType.BCC,
    TheAddresses);
    // subject field;
    msg.setSubject(Subject);
    // create the Multipart to be added the parts to;
    Multipart mp = new MimeMultipart();
    // create and fill the first message part;
    MimeBodyPart mbp = new MimeBodyPart();
    mbp.setText(Body);
    // attach the part to the multipart;
    mp.addBodyPart(mbp);
    // attach the files to the message;
    if (null != Attachments) {
    int StartIndex = 0, PosIndex = 0;
    while (-1 != (PosIndex = Attachments.indexOf("///",
    StartIndex))) {
    // create and fill other message parts;
    MimeBodyPart mbp = new MimeBodyPart();
    FileDataSource fds =
    new FileDataSource(Attachments.substring(StartIndex,
    PosIndex));
    mbp.setDataHandler(new DataHandler(fds));
    mbp.setFileName(fds.getName());
    mp.addBodyPart(mbp);
    PosIndex += 3;
    StartIndex = PosIndex;
    // last, or only, attachment file;
    if (StartIndex < Attachments.length()) {
    MimeBodyPart mbp = new MimeBodyPart();
    FileDataSource fds =
    new FileDataSource(Attachments.substring(StartIndex));
    mbp.setDataHandler(new DataHandler(fds));
    mbp.setFileName(fds.getName());
    mp.addBodyPart(mbp);
    // add the Multipart to the message;
    msg.setContent(mp);
    // set the Date: header;
    msg.setSentDate(new Date());
    // send the message;
    Transport.send(msg);
    } catch (MessagingException MsgException) {
    ErrorMessage[0] = MsgException.toString();
    Exception TheException = null;
    if ((TheException = MsgException.getNextException()) !=
    null)
    ErrorMessage[0] = ErrorMessage[0] + "\n" +
    TheException.toString();
    ErrorStatus = 1;
    return ErrorStatus;
    show errors java source "SendMail"
    CREATE OR REPLACE PACKAGE SendMailJPkg AS
    -- EOL is used to separate text line in the message body;
    EOL CONSTANT STRING(2) := CHR(13) || CHR(10);
    TYPE ATTACHMENTS_LIST IS
    TABLE OF VARCHAR2(4000);
    -- high-level interface with collections;
    FUNCTION SendMail(SMTPServerName IN STRING,
    Sender IN STRING,
    Recipient IN STRING,
    CcRecipient IN STRING DEFAULT '',
    BccRecipient IN STRING DEFAULT '',
    Subject IN STRING DEFAULT '',
    Body IN STRING DEFAULT '',
    ErrorMessage OUT STRING,
    Attachments IN ATTACHMENTS_LIST DEFAULT NULL)
    RETURN NUMBER;
    END SendMailJPkg;
    show errors
    CREATE OR REPLACE PACKAGE BODY SendMailJPkg AS
    PROCEDURE ParseAttachment(Attachments IN ATTACHMENTS_LIST,
    AttachmentList OUT VARCHAR2) IS
    AttachmentSeparator CONSTANT VARCHAR2(12) := '///';
    BEGIN
    -- boolean short-circuit is used here;
    IF Attachments IS NOT NULL AND Attachments.COUNT > 0 THEN
    AttachmentList := Attachments(Attachments.FIRST);
    -- scan the collection, skip first element since it has been
    -- already processed;
    -- accommodate for sparse collections;
    FOR I IN Attachments.NEXT(Attachments.FIRST) ..
    Attachments.LAST LOOP
    AttachmentList := AttachmentList || AttachmentSeparator ||
    Attachments(I);
    END LOOP;
    ELSE
    AttachmentList := '';
    END IF;
    END ParseAttachment;
    -- forward declaration;
    FUNCTION JSendMail(SMTPServerName IN STRING,
    Sender IN STRING,
    Recipient IN STRING,
    CcRecipient IN STRING,
    BccRecipient IN STRING,
    Subject IN STRING,
    Body IN STRING,
    ErrorMessage OUT STRING,
    Attachments IN STRING) RETURN NUMBER;
    -- high-level interface with collections;
    FUNCTION SendMail(SMTPServerName IN STRING,
    Sender IN STRING,
    Recipient IN STRING,
    CcRecipient IN STRING,
    BccRecipient IN STRING,
    Subject IN STRING,
    Body IN STRING,
    ErrorMessage OUT STRING,
    Attachments IN ATTACHMENTS_LIST) RETURN NUMBER IS
    AttachmentList VARCHAR2(4000) := '';
    AttachmentTypeList VARCHAR2(2000) := '';
    BEGIN
    ParseAttachment(Attachments,
    AttachmentList);
    RETURN JSendMail(SMTPServerName,
    Sender,
    Recipient,
    CcRecipient,
    BccRecipient,
    Subject,
    Body,
    ErrorMessage,
    AttachmentList);
    END SendMail;
    -- JSendMail's body is the java function SendMail.Send();
    -- thus, no PL/SQL implementation is needed;
    FUNCTION JSendMail(SMTPServerName IN STRING,
    Sender IN STRING,
    Recipient IN STRING,
    CcRecipient IN STRING,
    BccRecipient IN STRING,
    Subject IN STRING,
    Body IN STRING,
    ErrorMessage OUT STRING,
    Attachments IN STRING) RETURN NUMBER IS
    LANGUAGE JAVA
    NAME 'SendMail.Send(java.lang.String,
    java.lang.String,
    java.lang.String,
    java.lang.String,
    java.lang.String,
    java.lang.String,
    java.lang.String,
    java.lang.String[],
    java.lang.String) return int';
    END SendMailJPkg;
    show errors
    var ErrorMessage VARCHAR2(4000);
    var ErrorStatus NUMBER;
    -- enable SQL*PLUS output;
    SET SERVEROUTPUT ON
    -- redirect java output into SQL*PLUS buffer;
    exec dbms_java.set_output(5000);
    BEGIN
    :ErrorStatus := SendMailJPkg.SendMail(
    SMTPServerName => 'gmsmtp03.oraclecorp.com',
    Sender => '[email protected]',
    Recipient => '[email protected]',
    CcRecipient => '',
    BccRecipient => '',
    Subject => 'This is the subject line: Test JavaMail',
    Body => 'This is the body: Hello, this is a test' ||
    SendMailJPkg.EOL || 'that spans 2 lines',
    ErrorMessage => :ErrorMessage,
    Attachments => SendMailJPkg.ATTACHMENTS_LIST(
    '/tmp/on.lst',
    '/tmp/sqlnet.log.Z'
    END;
    print
    If I try and send file as attachments from the tmp directory, then everything works ok, but if I try to send the same file from any other directory, then it doesn't work. Can anyone help? Is there something wrong with the code, I'm not aware of anything that would make it directory specfic. Permissions are the same on /tmp as the new directory /NRS/Data/SystemX which I'm trying to send the file from now.

    well
    if u see the end of ur mail it shows the attachment dir there in which u have specified the address..why don't u do a change there or better have some in parameteres in the procedure for it..that would help in choosing the attachment directory on users wish?
    hope i am getting the problem right..if not kindly correct me in understanding the problem.
    thanX.

  • Problem sending attachements with gmail account on mail

    Hello:
    I have a lot of problems sending attachments with my gmail account using mail.
    1. Attachments are not big.
    2. I don't have the same problem with other non gmail accounts.
    3. When ever I have this problem I go to gamil.com and I am able to send the attachment with no problem.
    Any suggestions?
    Thanks

    No idea ?
    Nemrod

  • 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+

  • Problem sending mail with attachments???

    Hi Everybody,
    I have got a problem sending mail with attachments...
    I am able to send a plain mail ... but when i am trying to send mail along with an attachment ... its not being sent....
    its not showing any error it is simply hanging...
    what should i do?
    If u know any solns please do suggest me....
    Thanks in advance

    activation.jar is already there...
    initially i wrote a swing program as a front end and it was working abs fine... in my sense it was properly sending mails along with the attachments...
    when i changed the front-end to JSP handled by Servlets i am getting a problem...
    and even the swing program stopped working ...
    now swing program is getting compiled but it is hanging at run time showing an exception "Exception occured during event dispatching"
    i dont understand what probably may be the problem...
    if u can trace out, please give me any suggestions
    Thanks in advance and regards

  • I can't send attachments with Thunderbird?

    I can't send attachments with Thunderbird. I can write a message but when I click on Attach, I get the message "Thunderbird has stopped working. A problem has caused the program to stop working correctly. Windows will close the program and notify you if a solution is available." There is only a "CLOSE PROGRAM" button displayed and when I click on it Thunderbird stops running. I'm not sure whether this is a Thunderbird problem or a Windows 7 problem. Any ideas on what is causing this and how to fix it?

    Try to start Thunderbird in safe mode.
    https://support.mozilla.org/en-US/kb/safe-mode

  • Problems sending emails with iPhone 3G and outlook exchange

    I have a problem sending email with exchange. Receiving and answering mail works fine and calender updates work fine. However when I initiate an email from the phone it syncs and ends up in the sent folder in the computer but never reaches the recipient. I have tried this many times with different recipients and phones. It only happens from my iphone and ipad. Any suggestions?
    Any help much appreciated

    The iPhone you returned is still syncing against your server and locking out your account. Someone possibly has access to your mail data. I'd recommend having your Exchange Administrator install the Microsoft Exchange Server ActiveSync Web Administration Tool (http://www.microsoft.com/downloads/details.aspx?FamilyID=E6851D23-D145-4DBF-A2CC -E0B4C6301453&displaylang=en) and attempt to wipe/delete/block that other iPhone.
    Message was edited by: ethanm

  • Can not send attachments with emails on Me and aol Imap??

    I have an aol and MobileMe imap accounts set up with my mac mail, but I can not send any email with attachemnts no matter how small the smallest I have tried is 152Kb. I have been reeding the threads about not being able to send any email, but I can send and recive emails(with attachments) just not send with attachments.I have been able to send attachments with my aol Imap account before.
    I have recently signed up to Mobile me and created the Me Imap account, this is the first time I have had to send an attachment. Is it something to do with the Mobile me?? Any help much appreciated
    still relitivly new to Mac....

    Hi Kursten, and a warm welcome to the forums!
    Have you tried Port 587 instead of 25 for the .me account anyway?
    Mail>Preferences>Accounts>Outgoing SMTP>Server Settings...

  • Is there any problem to use multiple threads to send email with JavaMail

    Dear all,
    I am using JavaMail 1.3.2 to send emails with SMTP, it works very well for a long time.
    But one day, I found that the email service hanged and I could never send email again until I restart the tomcat. I found that the reason was a deadlock had been created, the required resource for sending email had not been released.
    I guess the error is due to multiple threads are sending email at the same time. I made a test to create seperate thread for sending each email. After few days, I found this deadlock happened again. So, my question is: Can I use JavaMail with multiple threads? If not, I may need to sychronized all the thread that using JavaMail. I would like to make sure this is the reason for causing the deadlock problem.
    Here is part of my code for using JavaMail:
    transport = session.getTransport("smtp");
    transport.connect(email_host, smtp_user, smtp_pass);
    message.saveChanges();
    transport.sendMessage(message,message.getAllRecipients());
    which is very standard call, and it worked well for a long time.
    Here is part for my thread dump on tomcat:
    (Thread-339)
    - waiting to lock <0x5447c180> (a sun.nio.cs.StandardCharsets)
    (Thread-342)
    - locked <0x5447c180> (a sun.nio.cs.StandardCharsets)
    It seems that these happened after call the method transport.sendMessage() or message.updateChanges()
    , and the underlying implementation may require the JRE StandardCharsets object. But the object had been locked and never be released. So, the sendMessage() or updateChanges() can't be completed.
    Please give me some helps if you have any idea about it.
    Thanks very much!
    Sirius

    Note that the Nightly build gets updated daily (and sometimes more than once in case of a respin) and it is always possible that something goes wrong and it doesn't work properly, so be prepared for issues if you decide to stay with the Nightly build and make sure to have the current release with its own profile installed as well in case of problems.
    See also:
    * http://kb.mozillazine.org/Testing_pre-release_versions
    *http://kb.mozillazine.org/Creating_a_new_Firefox_profile_on_Windows
    *http://kb.mozillazine.org/Shortcut_to_a_specific_profile
    *http://kb.mozillazine.org/Using_multiple_profiles_-_Firefox

  • How to send a message with javamail api

    Hi, anybody can tell me how i do to send a message with javamail?
    Thanks.
    Daniele.

    [rossifumi80],
    Here's a simple JavaMail application SendMessage.java that will connect a SMTP host and send a mail message out:
    import java.util.Properties;
    import javax.mail.*;
    import javax.mail.internet.*;
    public class SendMessage {
      public static void main (String args[]) throws Exception {
        String host = args[0];
        String from = args[1];
        String to = args[2];
        // Get system properties
        Properties props = System.getProperties();
        // Setup mail server
        props.put("mail.smtp.host", host);
        // Get session
        Session session = Session.getDefaultInstance(props, null);
        // Define message
        MimeMessage message = new MimeMessage(session);
        // Set the from address
        message.setFrom(new InternetAddress(from));
        // Set the to address
        message.addRecipient(Message.RecipientType.TO,
          new InternetAddress(to));
        // Set the subject
        message.setSubject("Hello JavaMail");
        // Set the content
        message.setText("Welcome to JavaMail");
        // Send message
        Transport.send(message);
    }HTH.
    Allen Lai
    Developer Technical Support
    SUN Microsystems
    http://www.sun.com/developers/support/

  • Sending � signs with JavaMail

    Hi chaps,
    At our company we use the JavaMail API through JNI to send emails externally to customers.
    Recently the business has decided that it would be nice to send pound (�) through, however it's not going to plan.
    Normally the messages are encoded in 7-bit which would seem to exclude the � (163), however it seems that it is first converted to a (=80, hex with no ascii correlation) and then to a Euro symbol.
    I've tried setting the "allow8bitmime" property in order to enable the SMTP service to support 8-bit encoding, but it's not working AND Microsoft say that our Exchange (v5.5) doesn't support 8-bit MIME types. The odd thing is that sending external emails via Exchange supports the � with no problems and is read in the mail reader as 8-bit encoded (!).
    Has anybody had any experience with issues like this ? Any reply appreciated.
    Thanks
    Ammonite

    Ammonite,
    I am working on a similar problem.. Did you say your
    email gets translated and prints the Euro symbol... I
    actually need out email to print Both the pound and
    the Euro and it does niether right now.. The current implementation I am working on will display a Euro instead of a pound, although this isn't by design. The message is encoded using "Quoted-Printable" and substitutes the pound for a =80 character. How this maps to a Euro is unknown to me :(
    In standard ascii the pound is outside the standard 7-bit encoding range (163) and featured in the Extended Set on the platform we use. I'm not sure about the Euro. The Iso-8859-1 charset which SH provided supports the pound in "Quoted-Printable" encoding, but this hasn't been well received by JavaMail MIME objects that I have tried.
    I haven't managed any sort of 8-bit encoding with JavaMail as yet, due to supposed lack of support in Exchange 5.5 and lack of response to the "allow8bitmime" property.
    does anyone know is using MimeMessage limit the
    message to ASCII characters only and does that rule
    out the Euro and the Pound symbol/
    It shoudn't rule them out, but I'm starting to believe that MimeMessages are necessarily helping things here :)

  • Problem sending email with attachment to another person

    04-08-2010 02:26 PM - last edited on 04-08-2010 03:05 PM
    I will try to keep this short.  I downloaded an app on one of my attorneys Curve 8330.  It is called Dataworx and lets her dictate then email the file to her secretary to convert and transcribe.  I can get a regular email to go through but when I try to send the one with the dictation it doesnt go and I get a message in the "sent using" section that says "unknown (secure)" and then under Message status it says "unable to find specified service"  When I use the same app on my Blackberry Storm I can dictate and email the file with no problem and open the attachment.  Can anyone help me.  I am a bit blackberry illiterate.  Thank you.
    UPDATE - the emails are finally coming to the intended recipient but there are no attachments on them.  Not even anything on our firewall saying they were removed.  very frustrating.
    We use an in house Microsoft Exchange server for our email and don't have Blackberry Enterprise or Blackberry Internet. 

    Luca, if one user is able to send attachments, the other should be able to as well.  However, if an attachment is too large, it won't be delivered.  
    Agreed, This does sound like a size limitation issue.
    Have the person try to send the same file from his outlook on his PC and see if he can send it out, that should be a good indication.

  • I can't send attachments with MAIL

    Please help me. Since I have installed Leopard, I have problems to send attachments by mail. People to whom I send, they don't receive them.
    Does anybody have any idea about to solve this trouble?
    Andrea from Italy

    so you look in your Sent folder and the email with attachment is shown as sent, and you do not receive an error message on your computer.
    then i would say it is purely a recipient error, and i am not sure how we can help on these pages not knowing what system they use or if on the web. do you have a friend to whom you can send an attachment that also uses a mac by any chance? does he/she receive the attachment fine, or no attachment either?
    hope this helps

  • Sending attachments with Netzero as SMTP server

    Since upgrading to Leopard last November, I have been unable to send emails with attachments. Email is received, with or without attachments, with no problem. Text emails can be sent with no problems. Netzero is the ISP, and is set as the outgoing SMTP server. Attachments were no problem with Tiger. I have also tried using gmail as the outgoing SMTP server, to no avail. I installed Thunderbird, and have the same result. I've contacted Netzero, and cannot get a definite response. I have also tried using the Mac dial-up software to by-pass Netzero but am able to send or receive with Mail.
    Is anyone able to send attachments to emails while using Netzero as the SMTP server? If so, I'd certainly appreciate advise, and I'd know that it's my problem somewhere. Thanks!

    Sammie - I have not been able to solve this frustrating problem
    yet....I have exchanged emails with Netzero, and they say the are
    "working on the problem". I have also posted information as feedback
    to Apple, at http://www.apple.com/feedback, which you may wish to do
    also.
    I have two work-arounds, as you may have seen in some of my posts at
    the discussion forums. If you haven't seen them, they are:
    First, you can use a webmail service...for instance, you can compose
    mail from your NetZero account (or gmail, for example), and upload
    your attachments before sending. This is slow, but works. Secondly, you can
    make a new, small (e.g., 25GB) partition on your Leopard disk, and
    install Tiger on that partition. I then drag and drop attachments
    into this partition from my Leopard disk, then restart on the Tiger
    disk. I am then able to use the Tiger Mail application to compose and send the
    message for me. This is cumbersome, but it does work, and I don't have to change providers.
    I'm glad to see that were not alone, though! Please let me know if you are able to figure this out...I'll keep you posted as well. Bill

Maybe you are looking for

  • Shuffle is not recognised by Windows or iTunes on first installation

    Hi Just got an Ipod shuffle, which was marked down in price due to missing ear phones. Tried the installation software but when asked to connect shuffle to check to see if it needs formating did so, and the shuffle is not recognised by windows or the

  • Using FM "SO_DOCUMENT_SEND_API1"  to send mail without attachment

    Hi, What are the parameters to be passed and their values to send a mail using SO_DOCUMENT_SEND_API1 EXPORT PARAMETERS :        document_data              = ?       sender_address             = sy-userid       sender_address_type        = 'INT'      

  • Struts Internalization

    Hi All , I am new to struts. I am trying internalization in struts. Could anyone please tell me the procedure for internalization. I am creating a resource file in classes folder of my application in tomcat 5.o I am adding the configuration parameter

  • Changed network name and now e-print e-mail address doesn't work

    I have a 6500A Plus Deskjet.  I have an hpconnected account and changed my e-print e-mail address to something I would remember.  Then I changed the name of my network.  I have to get a new claim code ..... I enter it and when I try to choose my e-pr

  • Deploying exchange portlet.

    I wanted to deploy the exchange portlet in Redhat 3.0 server AS 10g installation. I tried this with ORCLADMIN login. When tried to access this from http://mydomain:7778/exchange/providers/exchange the following error is displayed. Provider Test Page: