|
Mail. Длинна аттачмента на русском.
#34158542
Ссылка:
Ссылка на сообщение:
Ссылка с названием темы:
|
|
|
|
Подскажите пожалуйста как можно увеличить размер имени аттачмента на русском.
На данный момент длинна ограничена 38 символами...
Пример отправки
1. 2. 3. 4. 5. 6. 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. 19. 20. 21. 22. 23. 24. 25. 26. 27. 28. 29. 30. 31. 32. 33. 34. 35. 36. 37. 38. 39. 40. 41. 42. 43. 44. 45. 46. 47. 48. 49. 50. 51. 52. 53. 54. 55. 56. 57. 58. 59. 60. 61. 62. 63. 64. 65. 66. 67. 68. 69. 70. 71. 72. 73. 74. 75. 76. 77. 78. 79. 80. 81. 82. 83. 84. 85. 86. 87. 88.
public class testmail
{
static String dftMime = "application/octet-stream";
static String dftName = "filename.dat";
public static oracle.sql.NUMBER
send(String from,
String to,
String cc,
String bcc,
String subject,
String body,
String SMTPHost,
oracle.sql.BLOB attachmentData,
String attachmentType,
String attachmentFileName)
{
int rc = 0 ;
try
{
Properties props = System.getProperties();
props.put("mail.smtp.host", SMTPHost);
Message msg =
new MimeMessage(Session.getDefaultInstance(props, null ));
msg.setFrom( new InternetAddress(from));
if (to != null && to.length() > 0 )
msg.setRecipients(Message.RecipientType.TO,
InternetAddress.parse(to, false));
if (cc != null && cc.length() > 0 )
msg.setRecipients(Message.RecipientType.CC,
InternetAddress.parse(cc, false));
if (bcc != null && bcc.length() > 0 )
msg.setRecipients(Message.RecipientType.BCC,
InternetAddress.parse(bcc, false));
if ( subject != null && subject.length() > 0 )
msg.setSubject(subject);
else msg.setSubject("(no subject)");
msg.setSentDate( new Date());
if (attachmentData != null )
{
MimeBodyPart mbp1 = new MimeBodyPart();
mbp1.setText((body != null ? body : ""));
mbp1.setDisposition(Part.INLINE);
MimeBodyPart mbp2 = new MimeBodyPart();
String type =
(attachmentType != null ? attachmentType : dftMime);
String fileName = (attachmentFileName != null ?
attachmentFileName : dftName);
mbp2.setDisposition(Part.ATTACHMENT);
mbp2.setHeader("Content-Type","text/plain;charset=windows-1251");
mbp2.setFileName(javax.mail.internet.MimeUtility.encodeWord(fileName));
mbp2.setDataHandler( new
DataHandler( new BLOBDataSource(attachmentData, type))
);
MimeMultipart mp = new MimeMultipart();
mp.addBodyPart(mbp1);
mp.addBodyPart(mbp2);
msg.setContent(mp);
}
else
{
msg.setText((body != null ? body : ""));
}
Transport.send(msg);
rc = 1 ;
} catch (Exception e)
{
e.printStackTrace();
rc = 0 ;
} finally
{
return new oracle.sql.NUMBER(rc);
}
}
|
|
|