MessagingExceptionIOException while sending message in java?

前端 未结 8 943
说谎
说谎 2021-01-19 02:41

I use the following code to send mail.Text message sending is working fine but Mail with attachment is not working it gives the Exception.How to solve this

8条回答
  •  攒了一身酷
    2021-01-19 03:18

    Try to define the exact path of your file, the mail.txt.
    For example if it is in C: then go ahead and include the whole path like

     String filename = ("c:\\users\\mail.txt"); 
    

    and please note that sometime you might experience problems with ("c:\users\mail.txt") which has single backslashes so to be safe just make them double backslashes

    Also always make sure you use .printStackTrace() method since it will help you identify where exactly your problem will be arising so that when you search on that problem you will be in good position to know exactly what you will be looking for.

提交回复
热议问题