Error sending attachments mail

I am trying to send attachments using javamail and i tried out the example at:
http://developer.java.sun.com/developer/onlineTraining/JavaMail/exercises/MailAttach/index.html but I get an error on this line Transport.send(message), has anyone faced this problem, if you have, please do help me out man.
thanks
topraj

try this code..
import java.util.Properties;
import javax.mail.*;
import javax.mail.internet.*;
import javax.activation.*;
public class MailExample1 {
public static void main(String a[]) throws Exception {
     try {
     String host = "<your smtp server address here>";
     String to = "<to mailid here>";
     String from = "<From mail id here>";
     Properties props = new Properties();
     props.put("mail.smtp.host",host);
     Session session = Session.getDefaultInstance(props,null);
     MimeMessage message = new MimeMessage(session);
     BodyPart bp1 = new MimeBodyPart();
     bp1.setText("This is a message with multi media content sending gif files with text");
     Multipart mp = new MimeMultipart();
     mp.addBodyPart(bp1);
BodyPart bp2 = new MimeBodyPart();
     DataSource ds = new FileDataSource("Ivy.gif");
     bp2.setDataHandler(new DataHandler(ds));
     mp.addBodyPart(bp2);
     message.setFrom(new InternetAddress(from));
     message.addRecipient(Message.RecipientType.TO,new InternetAddress(to));
     message.setSubject("Test mail from java");
     message.setContent(mp);
     javax.mail.Transport.send(message);
     System.out.println("Message sent to: "+to);
     } catch(Exception e) { e.printStackTrace(); }
hope this will help you..
regards,
ashok

Similar Messages

  • Error sending e-mail.

    Hi,
    Since last 2 years this code was working perfectly and suddenly since last 2 days, this code is giving error, would you guys help me here. Please find below the ERROR CODE:
    E-mail couldn't be sent. Error returned: Failed to connect to mail.mudhranaa.co.in:25 [SMTP: Failed to connect socket: Connection refused (code: -1, response: )]. (EMAIL_FAILED)
    Thanks in advance for help.
    Regards,
    Venkatesha

    Hi Venkaesha and  NJFuller,
    I am also facing same issue.
    From last 2 months my application  was working  fine and able to send mails.  But suddenly my application is not able to send mails.
    FYI : I didnot change any settings related to SMTP server details.
    Error is ::
    com.adobe.idp.dsc.email.ConnectionFailedException: Failed to connect to email server:
    10.238.52.70. Reason: Could not connect to SMTP host: XX.X.X.X port: 25, response: -1
    at com.adobe.idp.dsc.email.EmailServiceImpl.sendMessage(EmailServiceImpl.java:473)
    Please help me on this.
    Thanks
    Praveen

  • Error Send E-MAIL

    Hi everybody!
    I am configuring KM Services, I need to utilize the Send E-MAIL function but when I try to send the following error gives me:  Not transport there you are been configured for e-mail.  Already configure the Channel (E-mail server) by which is sent for: System admin -> System Config -> KM -> Content Management. 
    Am i skiping any step?
    Please advice. Thanks..

    Hi ,
    Check the below steps mentioned in thread once again
    Configuration for Sending UM Mails?
    Koti Reddy

  • Error Sending E-mails

    I can receive e-mails all day long (with the very frequent "message could not be downloaded from server" text). But when I try to send e-mails I get the "Cannot Send Mail" error that I need to check my account settings for the outgoing server. But I have it configured the same as in Outlook. I have Charter Communications cable and I called Charter and the customer service person was clearly not technical and had no clue how to begin to help me figure this out. Help!
    Thanks!

    It does!!!! Just put cwmx.com with no password or
    account ID! THANKS GUYS!!!!!!!!!
    -Thad
    i have charter too in NC and I agree that the support team are truly clueless. Here is my current situation and has been since day 1 Any help is appreciated.
    1.My wifi home network is recognized by my iphone. When I go to browse it says Safari can't open the page because it can't find the server. (keep in mind i go to other wifi places and it works like a charm but it will not send out mail using my pop.charter account. using port 25 which was added during initial set up) also keep in mind i am running 2 laptops off the home network and they work fine.
    I updated the firmware on my router (Linksys WRT54GX2) and still no go on the iphone.
    2 I have tried using edge smtp to send out e-mail and it is not working for me.
    3. I can use edge for browing as well and getting e-mail but not sending
    4. Went to apple store genius bar in Raleigh NC they were baffled. They took out sims card and put back in, made a report told me to try it again when i got home. if not come back and they will give me a new phone. ( I live 2.5 hrs away from the store)
    I'm baffled as well. I truly do not think that getting a new phone will change my situation. I have tried just about every suggestion on this board (they are truly appreciated by me) from resetting to restoring to changing email smtp to changing router info the list goes on.
    I love my iphone but i am developing a love/hate relationship with it. I think it is too early in the relationship for that. Any more suggetions would again be greatly aqppreciated.

  • Error sending e-mail by Authentication unsucessful

    Hi PI Experts,
    I´m with problems for sending e-mails in SMTP Adapter Receiver.
    In SXI_MONITOR display as message: "server not responding OK to Auth; 535 5.7.3 Authentication unsucessful".
    This problem occurs only in QAS but in DEV and PRD is working...
    Is there any port configuration on the machine QAS or some other solution?
    TKS.
    COROL

    Hi,
    maybe it's the firewall issue ?
    can you ask your basis people if qas PI server has access to the mail server ?
    Regards,
    Michal Krawczyk

  • Error sending e-mail (alert report)

    hai,
    I am trying to send alert message and Report via e-mail.
    I caught up in this error .The eventvwr is giving this error.
    " The transport failed to connect to the server."
    Please help me to solve this problem.
    thanks in advance.

    Hai,
    Thanks for the reply...i had given the correct "Server Name: and
    Email Account for Alerting" in the
    Message Center management and restarted the Event Engine .....still i am getting the same error.....
    Please provide me the solution....
    thanks.

  • Error sending e-mail in SendEmailSample

    Hi,
    I got the following error when trying to send an e-mail with the provided sample:
    [2005/06/20 16:11:23] "{http://services.oracle.com/bpel/mail}sendMessageFault" has been thrown. Less
    <sendMessageFault xmlns="http://services.oracle.com/bpel/mail">
    <part name="summary">
    <summary>Mail account not found. The mail account "test_account " cannot be found in the metadata directory.</summary>
    </part>
    </sendMessageFault>
    What could be wrong? The test_account.xml file is in the deployed jar file and I configured it with my e-mail settings.
    regards,
    Jan

    Please run obant and cross check whether test_account.xml file is located in "${home}/domains/${deploy}/metadata/MailService". If still it doesnt work.
    Then please open .bpel file, search for test_account and remove any enter in the end if any. Then redeploy.

  • Snipping tool error- send to mail

    hi
    i am having proplem when tring to send screen shot with snipping tool to mail with outlook 2013
    error - the operation system is not presentky configured to runthis application
    win 8.1 pro + office 2013 H&B

    Hi,
    Considering that there is no permission to access related files.
    Please right click Snipping tool and choose "Run as admin", then try the send to feature.
    Also, we can also identify if the issue can be caused by corrupted user profile, please create new user account to check the issue.
    If in above steps, we can get it work fine, please follow these steps to fix it:
    First, take ownership of the %temp% folder:
    How to "Take Ownership" of a File, Folder, Drive, or Registry Key in Windows 8
    http://www.eightforums.com/tutorials/2808-take-ownership-file-folder-drive-registry-key-windows-8-a.html
    If the issue still persists after above fixed, please use process monitor to capture the system event when reproing this issue and upload the log file here for our research:
    Process Monitor v3.05
    http://technet.microsoft.com/en-us/sysinternals/bb896645.aspx
    How to use, please refer to this article:
    Using Process Monitor to capture system events
    http://www.sophos.com/en-us/support/knowledgebase/119038.aspx
    In addition, you can also check captured events to see if there is any access denied issue, and try to fix it yourself:
    Solving Access Denied Errors Using Process Monitor
    http://improve.dk/solving-access-denied-errors-using-process-monitor/
    Kate Li
    TechNet Community Support

  • Error: Error sending e-mail.

    Hi,
    I have created a form-based on CONTACT FORM Tutorial by
    Razvan Racasanu
    My form works just like CONTACT FORM, except it has more
    fields, it is submit to the database and email is send to 3
    different person. But i am getting the above mentioned error, while
    some help me here please.
    Regards,
    Venkatesha

    hi Gino,
    good that you have found the solution.
    So don't leave the thread open/unanswered
    kindly close the thread.
    Regards,
    SuryaD.

  • Error sending email in hyperion financial reporting

    Hi,
    While scheduling a batch for a report in HFR we are unable to get email notifications and we are getting the following error as below
    Batch "Shared Workspace pages/ Cashflow batch" finished at thursday,December 6,2012 10.25.14 AM EST
    Error sending e-mail.
    Can anyone give suggestions to reoslve this issue.
    Regards,
    Sai
    Edited by: 975434 on Dec 6, 2012 10:43 PM

    Hi Ajay,
    Today we are unable to connect to the VPN network due to some network issues, once we got connected i will try executing the following manner you replied.
    Mean while i tried to surf this issue in google browser and find out a link.
    http://www.elmajdal.net/win2k8/how_to_enable_telnet_in_windows_server_2008.aspx
    Can you please go through this link and confirm me whether this will assist me to resolve the issue.
    Regards,
    Sai

  • Error in E-mail Notification in BPM

    Hi folks,
      I have create one Simple BPM Project in which i Created one Notification Activity to send the mail
      but when i am starting my BPM Project it is showing the below error in history :
    Notification could not be sent to
    the following recipients:
    [email protected](Error sending e-mail),
    xxx@xxxcom(Error sending e-mail)
    and also the Task Event Notification is not working , giving following error :
    Event notification could not be
    sent to recipients [email protected] for task instance ID
    7800745f-3a34-11e4-b4c2-0000037bb076. Problem: Cannot send e-mail because the
    e-mail session cannot be retrieved
    Please give the solution for this.
    Thanks

    Hi Jun
    thnks for your reply
    below is the default trace error :
    Error
    sending notification email to recipient [email protected]. Reason:
    com.sap.bpem.base.mail.MailException: Cannot send e-mail because the e-mail
    session cannot be
    retrieved
    [EXCEPTION]
    com.sap.bpem.base.mail.MailException: Cannot send
    e-mail because the e-mail session cannot be retrieved
    at
    com.sap.bpem.base.mail.Send.initializeSession(Send.java:65)
    at
    com.sap.bpem.base.mail.Send.send(Send.java:116)
    at
    com.sap.bpem.base.mail.MailSenderBean.doSend(MailSenderBean.java:43)
    at
    com.sap.bpem.base.mail.MailSenderBean.surroundSend(MailSenderBean.java:74)
    at
    com.sap.bpem.base.mail.MailSenderBean.send(MailSenderBean.java:26)
    at
    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at
    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at
    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at
    java.lang.reflect.Method.invoke(Method.java:597)
    at
    com.sap.engine.services.ejb3.runtime.impl.RequestInvocationContext.proceedFinal(RequestInvocationContext.java:47)
    at
    com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:166)
    at
    com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatesTransition.invoke(Interceptors_StatesTransition.java:19)
    at
    com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179)
    at
    com.sap.engine.services.ejb3.runtime.impl.Interceptors_Resource.invoke(Interceptors_Resource.java:50)
    at
    com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179)
    at
    com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.doWorkWithAttribute(Interceptors_Transaction.java:37)
    at
    com.sap.engine.services.ejb3.runtime.impl.Interceptors_Transaction.invoke(Interceptors_Transaction.java:21)
    at
    com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179)
    at
    com.sap.engine.services.ejb3.runtime.impl.Interceptors_MethodRetry.invoke(Interceptors_MethodRetry.java:46)
    at
    com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179)
    at
    com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:191)
    at
    com.sap.engine.services.ejb3.runtime.impl.Interceptors_StatelessInstanceGetter.invoke(Interceptors_StatelessInstanceGetter.java:23)
    at
    com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179)
    at
    com.sap.engine.services.ejb3.runtime.impl.Interceptors_SecurityCheck.invoke(Interceptors_SecurityCheck.java:25)
    at
    com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179)
    at
    com.sap.engine.services.ejb3.runtime.impl.Interceptors_ExceptionTracer.invoke(Interceptors_ExceptionTracer.java:17)
    at
    com.sap.engine.services.ejb3.runtime.impl.AbstractInvocationContext.proceed(AbstractInvocationContext.java:179)
    at
    com.sap.engine.services.ejb3.runtime.impl.DefaultInvocationChainsManager.startChain(DefaultInvocationChainsManager.java:138)
    at
    com.sap.engine.services.ejb3.runtime.impl.DefaultEJBProxyInvocationHandler.invoke(DefaultEJBProxyInvocationHandler.java:164)
    at
    com.sun.proxy.$Proxy397.send(Unknown Source)
    at
    com.sap.bpem.notification.adapter.Notification.send(Notification.java:385)
    at
    com.sap.bpem.notification.adapter.Notification.sendToUser(Notification.java:325)
    at
    com.sap.bpem.notification.adapter.Notification.handleUser(Notification.java:269)
    at
    com.sap.bpem.notification.adapter.Notification.handlePrincipals(Notification.java:189)
    at
    com.sap.bpem.notification.adapter.Notification.process(Notification.java:152)
    at
    com.sap.bpem.notification.adapter.NotificationHandler$2.inCommit(NotificationHandler.java:112)
    at
    com.sap.glx.core.kernel.mmtx.PrimaryTransaction.inCommit(PrimaryTransaction.java:263)
    at
    com.sap.glx.core.kernel.mmtx.AbstractTransaction.do_commit(AbstractTransaction.java:230)
    at
    com.sap.glx.core.kernel.mmtx.AbstractTransaction.commit(AbstractTransaction.java:128)
    at
    com.sap.glx.core.kernel.execution.LeaderWorkerPool$Follower.run(LeaderWorkerPool.java:171)
    at
    com.sap.glx.core.resource.impl.common.WorkWrapper.run(WorkWrapper.java:58)
    at
    com.sap.glx.core.resource.impl.j2ee.J2EEResourceImpl$Sessionizer.run(J2EEResourceImpl.java:255)
    at
    com.sap.glx.core.resource.impl.j2ee.ServiceUserManager$ServiceUserImpersonator$1.run(ServiceUserManager.java:164)
    at
    java.security.AccessController.doPrivileged(Native Method)
    at
    javax.security.auth.Subject.doAs(Subject.java:335)
    at
    com.sap.glx.core.resource.impl.j2ee.ServiceUserManager$ServiceUserImpersonator.run(ServiceUserManager.java:161)
    at
    com.sap.engine.core.thread.impl3.ActionObject.run(ActionObject.java:37)
    at
    java.security.AccessController.doPrivileged(Native Method)
    at
    com.sap.engine.core.thread.impl3.SingleThread.execute(SingleThread.java:185)
    at
    com.sap.engine.core.thread.impl3.SingleThread.run(SingleThread.java:302)
    Caused
    by: javax.mail.AuthenticationFailedException
    at
    javax.mail.Service.connect(Service.java:319)
    at
    javax.mail.Service.connect(Service.java:169)
    at
    javax.mail.Service.connect(Service.java:118)
    at
    com.sap.bpem.base.mail.Send.initializeSession(Send.java:59)
    ... 49 more

  • Error(-101) encountered when trying to send a mail

    Hi,
    I am trying to send a mail through Business One 2005A. When i click on the email icon, a pop up window appears that asks if i want to attach an edited report with the mail. when i click "Yes", i get an error message error(-101) encountered. but if i click "No", i dont get that error. Can anyone please let me know what this error is all about?
    Regards,
    Harsh

    Hi Fulvia,
    This could be caused by folder permissions. Try creating a new share on the server (I typically create a share off the root of the drive, called something like B1_MAIL or SBO_MAIL), granting Full Control to all domain users and then mapping your attachments path in General Settings to this new folder. If this solves the problem then you can tighten up the security to fit your requirements afterwards.
    Hope this helps,
    Owen

  • Error message sending attachments using Comcast webmail and Safari

    I'm using a G3 iMac, with 640MB memory (sorry, can't find the RAM free space), everything is working fine except that just last week, I all of a sudden cannot send attachements through my "comcast message center" webmail using Safari. I spent hours with Comcast, going through different procedures, with no good result. They are convinced it's an "apple problem" but of course I think it's them.
    I consistently get an error message "appending message failed" . . . but it's odd because for awhile last week I could not receive or send ANY e-mails (with the same error message), attachments or not, and now it seems I can only send OR receive e-mails with NO attachments. And then this morning, I was able to send several attachments before it went back to the error message again (and I spent another two hours on the phone with Comcast). I opened an account with Mail and (using my Comcast address in a POP account) was able to send all the attachments I could not send through Comcast Message Center.
    Hope I gave enough information. Please let me know if you think this is an "Apple problem"
    iMac - G3   Mac OS X (10.4.3)  

    I just tried to upload a PDF attachment using Comcast's webmail and was successful. I'd say it's a problem on their end since it's saying "appending message failed." Obviously, they are either not receiving all of the file, or the server just kicks back some message.
    I'd say use Mail.app for your webmail if at all possible as it's easier to use and faster to access!
    -Ryan

  • 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

  • Mail 3.3 won't send attachments

    Ever since upgrading to Leopard 10.5.4 I haven't been able to send attachments over about 30Kb. I have dialup with NetZero and have checked all of the modem and Network settings. I've been using this same dialup for 5 yrs or so and have never had a problem with previous OS's. The last was 10.4.11. When I attempt to send an attachment of over 30Kb, Mail will spin for 5 min. or so and finally generate the following: "Cannot send message using the server smtp.netzero.com". I checked with NetZero and that is the correct address for their outgoing mail server.To check that I didn't have some other problem I tried FTPing a file via an FTP client and that worked fine.
    I did try sending an attachment using the browser based email program from NetZero and had a similar problem...I'm using Safari 3.1.2 for that BTW. In NetZero it spun it's wheel for a few minutes and simply didn't load the attachment. This leads me to think that this is more of an OS issue in that it does the same thing with 2 different programs.
    Anyone have any thoughts? Thanks in advance.

    I'm having similar trouble with Mail 3.3 after upgrading to Leopard despite years of trouble-free use with exactly the same set up on previous OSs and versions of Mail.
    It boils down to frequent but erratic SMPT errors - sometimes the mail goes, sometimes it doesn't. I've found that clicking the Connection Doctor button sometimes helps. But sometimes it doesn't.
    Sometimes it's only emails with attachments that get snagged, other times it's all emails.
    Why does something that used to work fine have to get worse with an upgraded version? iPhoto seems to have got worse too (no dragging to folders from full-screen view). Come on, Apple, sort it out or we'll all have to abandon your Apps.

Maybe you are looking for

  • Switching Data Source for a report with stored procedure

    Post Author: ysbn CA Forum: Data Connectivity and SQL I've created a report and deployed it on a Crystal Server. The report is based on a certain stored procedure which also exists on other DB machines in my environment (Oracle machines). When I try

  • Messagging

    I connect my Facebook with my lumia 520, i can send message but i don't receive any , also i m only allowded to send my loction , not pictures ,videos or audio ,.. Why soo?

  • Premiere Pro fails to install

    Premiere Pro fails to install as a trial or as a coud app. Here is the error code that I receive. PLEASE HELP!!!!!!! Exit Code: 34  -------------------------------------- Summary --------------------------------------  - 1 fatal error(s), 0 error(s),

  • Workflow into and out of After Effects

    I'm just starting to learn how to use After Effects CC, with the help of the associated Adobe "Classroom In A Book" to get me started.  Naturally, I'm keen to start using AE myself with my own projects, but this raised a question I can't find the ans

  • Correct streamclip settings help

    I've imported VHS analog video through my Canopus ADVC-110, with Easy Setup DV-NTSC DV Converter. Now I want to add some other files from a DVD which are AVI files. In Using MPEGStreamclip, I've tried various export settings. When I import the files,