Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Java mail attachment raw content appended to mail body  RSS feed

 
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am  sending  attachment from Yahoo server.
My setting are:




Method to send mail is



sample of received file:

 
Sheriff
Posts: 23700
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dunno... you might want to have a look at this tutorial for example, which looks much like your code but has some minor (but possibly significant) differences.
 
Bartender
Posts: 2038
273
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Versha Agarwal wrote:I am  sending  attachment from Yahoo server ..


To be clear: you are sending the from a Java application through Yahoo, and somehow retrieving the email - is that correct?

How are you retrieving/viewing the email (the message that you included in your post) - do you have another Java application, are you using an email client?
 
Versha Agarwal
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Ron McLeod wrote:

Versha Agarwal wrote:I am  sending  attachment from Yahoo server ..


To be clear: you are sending the from a Java application through Yahoo, and somehow retrieving the email - is that correct?

How are you retrieving/viewing the email (the message that you included in your post) - do you have another Java application, are you using an email client?



I am opening it  using  my email id in gmail (using browser) https://mail.google.com/mail/u/0/#inbox
 
Versha Agarwal
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Versha Agarwal wrote:

Ron McLeod wrote:

Versha Agarwal wrote:I am  sending  attachment from Yahoo server ..


To be clear: you are sending the from a Java application through Yahoo, and somehow retrieving the email - is that correct?

How are you retrieving/viewing the email (the message that you included in your post) - do you have another Java application, are you using an email client?



I am opening it  using  my email id in gmail (using browser) https://mail.google.com/mail/u/0/#inbox



Yahho to yahho  is working fine.
But if recipient is gmail/rediff or any other it is not working.
 
Versha Agarwal
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Versha Agarwal wrote:

Versha Agarwal wrote:

Ron McLeod wrote:

Versha Agarwal wrote:I am  sending  attachment from Yahoo server ..


To be clear: you are sending the from a Java application through Yahoo, and somehow retrieving the email - is that correct?

How are you retrieving/viewing the email (the message that you included in your post) - do you have another Java application, are you using an email client?



I am opening it  using  my email id in gmail (using browser) https://mail.google.com/mail/u/0/#inbox



Yahho to yahho  is working fine.
But if recipient is gmail/rediff or any other it is not working.



Even I tried ByteArrayDataSource too. Same problem persists.
byte[] bFile = Files.readAllBytes(new File(path).toPath());
messageBodyPart.setDataHandler(new DataHandler(new ByteArrayDataSource(bFile, "application/pdf")) );
multipart.addBodyPart(messageBodyPart);
 
Paul Clapham
Sheriff
Posts: 23700
50
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:I dunno... you might want to have a look at this tutorial for example, which looks much like your code but has some minor (but possibly significant) differences.



Did you try this yet?
 
Ron McLeod
Bartender
Posts: 2038
273
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was able to run your code using my Gmail account and it worked fine.


One change that I made as to replace this
with this
I also enabled debugging in JavaMail
This is how the received email appeared on my email client




This is the debug output

I used version 1.4.2 of JavaMail
 
Versha Agarwal
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I already  tried
String[] token = path.split("[\\\\|/]");
String filename = token[token.length - 1];

messageBodyPart.attachFile(path, "application/pdf", "base64");
Sending you debug output used with DataSource and messageBodyPart.setDataHandler()

 
Versha Agarwal
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Sending you debug output used with messageBodyPart.attachFile(path, "application/pdf", "base64");

 
Versha Agarwal
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please try from yahoo server.
 
Ron McLeod
Bartender
Posts: 2038
273
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't have a Yahoo account.  Maybe you should try sending from Gmail and see if you get the same (successful) result that I did.

Did you using messageBodyPart2.attachFile(path); to attach the document?
 
Versha Agarwal
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Same method is working from another link.
But not for order pdf.
 
Ron McLeod
Bartender
Posts: 2038
273
Android Angular Framework Eclipse IDE Java Linux MySQL Database Redhat TypeScript
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Versha Agarwal wrote:Same method is working from another link.  But not for order pdf.


Are you saying that some types of attachments get delivered as expected, but others do not?
 
Versha Agarwal
Greenhorn
Posts: 29
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Even same type. I am able to send PDF from other link but it is not working for order.
 
Versha Agarwal
Greenhorn
Posts: 29
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Problem Solved.
In subject \r\n chracters was appended befor order code.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!