| 472 | }; |
| 473 | |
| 474 | function writeattachemnt_stream(attachment, obj, stream) { |
| 475 | |
| 476 | var name = attachment.name; |
| 477 | var isCalendar = attachment.extension === 'ics'; |
| 478 | var message = []; |
| 479 | |
| 480 | message.push('--' + obj.boundary); |
| 481 | |
| 482 | if (!isCalendar) { |
| 483 | if (attachment.contentId) { |
| 484 | message.push('Content-Disposition: inline; filename="' + name + '"'); |
| 485 | message.push('Content-ID: <' + attachment.contentId + '>'); |
| 486 | } else |
| 487 | message.push('Content-Disposition: attachment; filename="' + name + '"'); |
| 488 | } |
| 489 | |
| 490 | message.push('Content-Type: ' + attachment.type + ';' + (isCalendar ? ' charset="utf-8"; method=REQUEST' : '')); |
| 491 | message.push('Content-Transfer-Encoding: base64'); |
| 492 | message.push(CRLF); |
| 493 | mailer.$writeline(obj, message.join(CRLF)); |
| 494 | |
| 495 | stream.$mailer = mailer; |
| 496 | stream.$mailerobj = obj; |
| 497 | stream.on('data', writeattachment_data); |
| 498 | |
| 499 | CLEANUP(stream, function() { |
| 500 | mailer.$writeline(obj, CRLF); |
| 501 | mailer.$writeattachment(obj); |
| 502 | }); |
| 503 | |
| 504 | } |
| 505 | |
| 506 | function writeattachment_data(chunk) { |
| 507 | |