aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/rfc822/MCMessageBuilder.cc
blob: ecec743c32e85fa733420eeaf50dcaa3faba7235 (plain)
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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
#include "MCMessageBuilder.h"

#include "MCMessageHeader.h"
#include "MCAttachment.h"
#include "MCMessageParser.h"

#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <libetpan/libetpan.h>

using namespace mailcore;

static char * generate_boundary(const char * boundary_prefix);
struct mailmime * part_multiple_new(const char * type, const char * boundary_prefix);
static struct mailmime *
part_new_empty(struct mailmime_content * content,
               struct mailmime_fields * mime_fields,
               const char * boundary_prefix,
               int force_single);

static struct mailmime * get_multipart_alternative(const char * boundary_prefix)
{
	struct mailmime * mime;
	
	mime = part_multiple_new("multipart/alternative", boundary_prefix);
	
	return mime;
}

static struct mailmime * get_multipart_related(const char * boundary_prefix)
{
	struct mailmime * mime;
	
	mime = part_multiple_new("multipart/related", boundary_prefix);
	
	return mime;
}

static int add_attachment(struct mailmime * mime,
    struct mailmime * mime_sub,
    const char * boundary_prefix)
{
    struct mailmime * saved_sub;
    struct mailmime * mp;
    int res;
    int r;
    
    switch (mime->mm_type) {
        case MAILMIME_SINGLE:
            res = MAILIMF_ERROR_INVAL;
            goto err;
            
        case MAILMIME_MULTIPLE:
            r = mailmime_add_part(mime, mime_sub);
            if (r != MAILIMF_NO_ERROR) {
                res = MAILIMF_ERROR_MEMORY;
                goto err;
            }
            
            return MAILIMF_NO_ERROR;
    }
    
    /* MAILMIME_MESSAGE */
    
    if (mime->mm_data.mm_message.mm_msg_mime == NULL) {
        /* there is no subpart, we can simply attach it */
        
        r = mailmime_add_part(mime, mime_sub);
        if (r != MAILIMF_NO_ERROR) {
            res = MAILIMF_ERROR_MEMORY;
            goto err;
        }
        
        return MAILIMF_NO_ERROR;
    }
    
    if (mime->mm_data.mm_message.mm_msg_mime->mm_type == MAILMIME_MULTIPLE &&
        strcasecmp(mime->mm_data.mm_message.mm_msg_mime->mm_content_type->ct_subtype, "alternative") != 0) {
        /* in case the subpart is multipart, simply attach it to the subpart */
        
        return mailmime_add_part(mime->mm_data.mm_message.mm_msg_mime, mime_sub);
    }
    
    /* we save the current subpart, ... */
    
    saved_sub = mime->mm_data.mm_message.mm_msg_mime;
    
    /* create a multipart */
    
    mp = part_multiple_new("multipart/mixed", boundary_prefix);
    if (mp == NULL) {
        res = MAILIMF_ERROR_MEMORY;
        goto err;
    }
    
    /* detach the saved subpart from the parent */
    
    mailmime_remove_part(saved_sub);
    
    /* the created multipart is the new child of the parent */
    
    r = mailmime_add_part(mime, mp);
    if (r != MAILIMF_NO_ERROR) {
        res = MAILIMF_ERROR_MEMORY;
        goto free_mp;
    }
    
    /* then, attach the saved subpart and ... */
    
    r = mailmime_add_part(mp, saved_sub);
    if (r != MAILIMF_NO_ERROR) {
        res = MAILIMF_ERROR_MEMORY;
        goto free_saved_sub;
    }
    
    /* the given part to the parent */
    
    r = mailmime_add_part(mp, mime_sub);
    if (r != MAILIMF_NO_ERROR) {
        res = MAILIMF_ERROR_MEMORY;
        goto free_saved_sub;
    }
    
    return MAILIMF_NO_ERROR;
    
free_mp:
    mailmime_free(mp);
free_saved_sub:
    mailmime_free(saved_sub);
err:
    return res;
}

static struct mailmime * get_text_part(const char * mime_type, const char * charset, const char * content_id,
                                const char * description,
								const char * text, size_t length, int encoding_type)
{
	struct mailmime_fields * mime_fields;
	struct mailmime * mime;
	struct mailmime_content * content;
	struct mailmime_parameter * param;
	struct mailmime_disposition * disposition;
	struct mailmime_mechanism * encoding;
	char * dup_content_id;
    char * dup_description;
    
	encoding = mailmime_mechanism_new(encoding_type, NULL);
	disposition = mailmime_disposition_new_with_data(MAILMIME_DISPOSITION_TYPE_INLINE,
													 NULL, NULL, NULL, NULL, (size_t) -1);
    dup_content_id = NULL;
    if (content_id != NULL)
        dup_content_id = strdup(content_id);
    dup_description = NULL;
    if (dup_description != NULL)
        dup_description = strdup(description);
	mime_fields = mailmime_fields_new_with_data(encoding,
                                                dup_content_id, dup_description, disposition, NULL);
	
	content = mailmime_content_new_with_str(mime_type);
	if (charset == NULL) {
		param = mailmime_param_new_with_data((char *) "charset", (char *) "utf-8");
	}
	else {
		param = mailmime_param_new_with_data((char *) "charset", (char *) charset);
	}
	clist_append(content->ct_parameters, param);
	mime = part_new_empty(content, mime_fields, NULL, 1);
	mailmime_set_body_text(mime, (char *) text, length);
	
	return mime;
}

static struct mailmime * get_plain_text_part(const char * mime_type, const char * charset, const char * content_id,
                                      const char * description,
                                      const char * text, size_t length)
{
    bool needsQuotedPrintable;
    int mechanism;
    
    needsQuotedPrintable = false;
    for(size_t i = 0 ; i < length ; i ++) {
        if ((text[i] & (1 << 7)) != 0) {
            needsQuotedPrintable = true;
        }
    }
    
    mechanism = MAILMIME_MECHANISM_7BIT;
    if (needsQuotedPrintable) {
        mechanism = MAILMIME_MECHANISM_QUOTED_PRINTABLE;
    }
    return get_text_part(mime_type, charset, content_id, description, text, length, mechanism);
}

static struct mailmime * get_other_text_part(const char * mime_type, const char * charset, const char * content_id,
                                      const char * description,
                                      const char * text, size_t length)
{
    return get_text_part(mime_type, charset, content_id, description, text, length, MAILMIME_MECHANISM_QUOTED_PRINTABLE);
}

static struct mailmime * get_file_part(const char * filename, const char * mime_type, int is_inline,
                                       const char * content_id,
                                       const char * content_description,
                                       const char * text, size_t length)
{
	char * disposition_name;
	int encoding_type;
	struct mailmime_disposition * disposition;
	struct mailmime_mechanism * encoding;
	struct mailmime_content * content;
	struct mailmime * mime;
	struct mailmime_fields * mime_fields;
	char * dup_content_id;
    char * dup_content_description;

	disposition_name = NULL;
	if (filename != NULL) {
		disposition_name = strdup(filename);
	}
	if (is_inline) {
		disposition = mailmime_disposition_new_with_data(MAILMIME_DISPOSITION_TYPE_INLINE,
														 disposition_name, NULL, NULL, NULL, (size_t) -1);
	}
	else {
		disposition = mailmime_disposition_new_with_data(MAILMIME_DISPOSITION_TYPE_ATTACHMENT,
														 disposition_name, NULL, NULL, NULL, (size_t) -1);
	}
	content = mailmime_content_new_with_str(mime_type);
	
	encoding_type = MAILMIME_MECHANISM_BASE64;
	encoding = mailmime_mechanism_new(encoding_type, NULL);
    dup_content_id = NULL;
    if (content_id != NULL)
        dup_content_id = strdup(content_id);
    dup_content_description = NULL;
    if (content_description != NULL)
        dup_content_description = strdup(content_description);
	mime_fields = mailmime_fields_new_with_data(encoding,
												dup_content_id, dup_content_description, disposition, NULL);
	mime = part_new_empty(content, mime_fields, NULL, 1);
	mailmime_set_body_text(mime, (char *) text, length);
	
	return mime;
}

#define MIME_ENCODED_STR(str) (str != NULL ? str->encodedMIMEHeaderValue()->bytes() : NULL)

static struct mailmime * mime_from_attachment(Attachment * att)
{
    struct mailmime * mime;
    Data * data;
    int r;

    data = att->data();
    if (data == NULL) {
        data = Data::data();
    }
    if (att->mimeType()->lowercaseString()->isEqual(MCSTR("message/rfc822"))) {
        size_t indx = 0;
        r = mailmime_parse(data->bytes(), data->length(), &indx, &mime);
        if (r != MAILIMF_NO_ERROR)
            return NULL;
    }
    else if (att->isInlineAttachment() && att->mimeType()->lowercaseString()->isEqual(MCSTR("text/plain"))) {
        mime = get_plain_text_part(MCUTF8(att->mimeType()), MCUTF8(att->charset()),
            MCUTF8(att->contentID()),
            MIME_ENCODED_STR(att->contentDescription()),
            data->bytes(), data->length());
    }
    else if (att->isInlineAttachment() && att->mimeType()->lowercaseString()->hasPrefix(MCSTR("text/"))) {
        mime = get_other_text_part(MCUTF8(att->mimeType()), MCUTF8(att->charset()),
            MCUTF8(att->contentID()),
            MIME_ENCODED_STR(att->contentDescription()),
            data->bytes(), data->length());
    }
    else {
        mime = get_file_part(MIME_ENCODED_STR(att->filename()),
            MCUTF8(att->mimeType()), att->isInlineAttachment(),
            MCUTF8(att->contentID()),
            MIME_ENCODED_STR(att->contentDescription()),
            data->bytes(), data->length());
    }
    return mime;
}

static struct mailmime * multipart_related_from_attachments(Attachment * htmlAttachment,
    Array * attachments, const char * boundary_prefix)
{
    if ((attachments != NULL) && (attachments->count() > 0)) {
        struct mailmime * submime;
        struct mailmime * mime;
        
        mime = get_multipart_related(boundary_prefix);
        
        submime = mime_from_attachment(htmlAttachment);
        add_attachment(mime, submime, boundary_prefix);
        
        for(unsigned int i = 0 ; i < attachments->count() ; i ++) {
            Attachment * attachment;
            
            attachment = (Attachment *) attachments->objectAtIndex(i);
            submime = mime_from_attachment(attachment);
            add_attachment(mime, submime, boundary_prefix);
        }
        
        return mime;
    }
    else {
        struct mailmime * mime;
        
        mime = mime_from_attachment(htmlAttachment);
        
        return mime;
    }
}

static struct mailmime *
part_new_empty(struct mailmime_content * content,
               struct mailmime_fields * mime_fields,
               const char * boundary_prefix,
               int force_single)
{
    struct mailmime * build_info;
    clist * list;
    int r;
    int mime_type;
    
    list = NULL;
    
    if (force_single) {
        mime_type = MAILMIME_SINGLE;
    }
    else {
        switch (content->ct_type->tp_type) {
            case MAILMIME_TYPE_DISCRETE_TYPE:
                mime_type = MAILMIME_SINGLE;
                break;
                
            case MAILMIME_TYPE_COMPOSITE_TYPE:
                switch (content->ct_type->tp_data.tp_composite_type->ct_type) {
                    case MAILMIME_COMPOSITE_TYPE_MULTIPART:
                        mime_type = MAILMIME_MULTIPLE;
                        break;
                        
                    case MAILMIME_COMPOSITE_TYPE_MESSAGE:
                        if (strcasecmp(content->ct_subtype, "rfc822") == 0)
                            mime_type = MAILMIME_MESSAGE;
                        else
                            mime_type = MAILMIME_SINGLE;
                        break;
                        
                    default:
                        goto err;
                }
                break;
                
            default:
                goto err;
        }
    }
    
    if (mime_type == MAILMIME_MULTIPLE) {
        char * attr_name;
        char * attr_value;
        struct mailmime_parameter * param;
        clist * parameters;
        char * boundary;
        
        list = clist_new();
        if (list == NULL)
            goto err;
        
        attr_name = strdup("boundary");
        if (attr_name == NULL)
            goto free_list;
        
        boundary = generate_boundary(boundary_prefix);
        attr_value = boundary;
        if (attr_name == NULL) {
            free(attr_name);
            goto free_list;
        }
        
        param = mailmime_parameter_new(attr_name, attr_value);
        if (param == NULL) {
            free(attr_value);
            free(attr_name);
            goto free_list;
        }
        
        if (content->ct_parameters == NULL) {
            parameters = clist_new();
            if (parameters == NULL) {
                mailmime_parameter_free(param);
                goto free_list;
            }
        }
        else
            parameters = content->ct_parameters;
        
        r = clist_append(parameters, param);
        if (r != 0) {
            clist_free(parameters);
            mailmime_parameter_free(param);
            goto free_list;
        }
        
        if (content->ct_parameters == NULL)
            content->ct_parameters = parameters;
    }
    
    build_info = mailmime_new(mime_type,
                              NULL, 0, mime_fields, content,
                              NULL, NULL, NULL, list,
                              NULL, NULL);
    if (build_info == NULL) {
        clist_free(list);
        return NULL;
    }
    
    return build_info;
    
free_list:
    clist_free(list);
err:
    return NULL;
}

struct mailmime * part_multiple_new(const char * type, const char * boundary_prefix)
{
    struct mailmime_fields * mime_fields;
    struct mailmime_content * content;
    struct mailmime * mp;
    
    mime_fields = mailmime_fields_new_empty();
    if (mime_fields == NULL)
        goto err;
    
    content = mailmime_content_new_with_str(type);
    if (content == NULL)
        goto free_fields;
    
    mp = part_new_empty(content, mime_fields, boundary_prefix, 0);
    if (mp == NULL)
        goto free_content;
    
    return mp;
    
free_content:
    mailmime_content_free(content);
free_fields:
    mailmime_fields_free(mime_fields);
err:
    return NULL;
}

#define MAX_MESSAGE_ID 512

static char * generate_boundary(const char * boundary_prefix)
{
    char id[MAX_MESSAGE_ID];
    time_t now;
    char name[MAX_MESSAGE_ID];
    long value;
    
    now = time(NULL);
    value = random();
    
    gethostname(name, MAX_MESSAGE_ID);
    
    if (boundary_prefix == NULL)
        boundary_prefix = "";
    
    snprintf(id, MAX_MESSAGE_ID, "%s%lx_%lx_%x", boundary_prefix, now, value, getpid());
    
    return strdup(id);
}

void MessageBuilder::init()
{
    mHTMLBody = NULL;
    mTextBody = NULL;
	mAttachments = NULL;
	mRelatedAttachments = NULL;
    mBoundaryPrefix = NULL;
}
	
MessageBuilder::MessageBuilder()
{
    init();
}

MessageBuilder::MessageBuilder(MessageBuilder * other) : AbstractMessage(other)
{
    init();
    setHTMLBody(other->mHTMLBody);
    setTextBody(other->mTextBody);
    setAttachments(other->mAttachments);
    setRelatedAttachments(other->mRelatedAttachments);
    MC_SAFE_REPLACE_COPY(String, mBoundaryPrefix, other->mBoundaryPrefix);
}

MessageBuilder::~MessageBuilder()
{
    MC_SAFE_RELEASE(mHTMLBody);
    MC_SAFE_RELEASE(mTextBody);
    MC_SAFE_RELEASE(mAttachments);
    MC_SAFE_RELEASE(mRelatedAttachments);
    MC_SAFE_RELEASE(mBoundaryPrefix);
}
	
String * MessageBuilder::description()
{
    String * result = String::string();
    result->appendUTF8Format("<%s:%p\n", className()->UTF8Characters(), this);
    if (header() != NULL) {
        result->appendString(header()->description());
        result->appendUTF8Characters("\n");
    }
    if (mHTMLBody != NULL) {
        result->appendUTF8Characters("-- html body --\n");
        result->appendString(mHTMLBody);
        result->appendUTF8Characters("\n");
    }
    if (mTextBody != NULL) {
        result->appendUTF8Characters("-- text body --\n");
        result->appendString(mTextBody);
        result->appendUTF8Characters("\n");
    }
    if (mAttachments != NULL) {
        result->appendUTF8Characters("-- attachments --\n");
        result->appendString(mAttachments->description());
        result->appendUTF8Characters("\n");
    }
    if (mRelatedAttachments != NULL) {
        result->appendUTF8Characters("-- related attachments --\n");
        result->appendString(mRelatedAttachments->description());
        result->appendUTF8Characters("\n");
    }
    result->appendUTF8Characters(">");
    
    return result;
}

Object * MessageBuilder::copy()
{
    return new MessageBuilder(this);
}

void MessageBuilder::setHTMLBody(String * htmlBody)
{
    MC_SAFE_REPLACE_COPY(String, mHTMLBody, htmlBody);
}

String * MessageBuilder::htmlBody()
{
    return mHTMLBody;
}

void MessageBuilder::setTextBody(String * textBody)
{
    MC_SAFE_REPLACE_COPY(String, mTextBody, textBody);
}

String * MessageBuilder::textBody()
{
    return mTextBody;
}

void MessageBuilder::setAttachments(Array * attachments)
{
    MC_SAFE_REPLACE_COPY(Array, mAttachments, attachments);
}

Array * MessageBuilder::attachments()
{
    return mAttachments;
}

void MessageBuilder::addAttachment(Attachment * attachment)
{
    if (mAttachments == NULL) {
        mAttachments = new Array();
    }
    mAttachments->addObject(attachment);
}

void MessageBuilder::setRelatedAttachments(Array * attachments)
{
    MC_SAFE_REPLACE_COPY(Array, mRelatedAttachments, attachments);
}

Array * MessageBuilder::relatedAttachments()
{
    return mRelatedAttachments;
}

void MessageBuilder::addRelatedAttachment(Attachment * attachment)
{
    if (mRelatedAttachments == NULL) {
        mRelatedAttachments = new Array();
    }
    mRelatedAttachments->addObject(attachment);
}

void MessageBuilder::setBoundaryPrefix(String * boundaryPrefix)
{
    MC_SAFE_REPLACE_COPY(String, mBoundaryPrefix, boundaryPrefix);
}

String * MessageBuilder::boundaryPrefix()
{
    return mBoundaryPrefix;
}

Data * MessageBuilder::dataAndFilterBcc(bool filterBcc)
{
    Data * data;
    MMAPString * str;
    int col;

    struct mailmime * htmlPart;
    struct mailmime * textPart;
    struct mailmime * altPart;
    struct mailmime * mainPart;

    htmlPart = NULL;
    textPart = NULL;
    altPart = NULL;
    mainPart = NULL;

    if (htmlBody() != NULL) {
        Attachment * htmlAttachment;

        htmlAttachment = Attachment::attachmentWithHTMLString(htmlBody());
        htmlPart = multipart_related_from_attachments(htmlAttachment, mRelatedAttachments,
            MCUTF8(mBoundaryPrefix));
    }

    if (textBody() != NULL) {
        Attachment * textAttachment;

        textAttachment = Attachment::attachmentWithText(textBody());
        textPart = mime_from_attachment(textAttachment);
    }
    else if (htmlBody() != NULL) {
        Attachment * textAttachment;

        textAttachment = Attachment::attachmentWithText(htmlBody()->flattenHTML());
        textPart = mime_from_attachment(textAttachment);
    }

    if ((textPart != NULL) && (htmlPart != NULL)) {
        altPart = get_multipart_alternative(MCUTF8(mBoundaryPrefix));
        mailmime_smart_add_part(altPart, textPart);
        mailmime_smart_add_part(altPart, htmlPart);
        mainPart = altPart;
    }
    else if (textPart != NULL) {
        mainPart = textPart;
    }
    else if (htmlPart != NULL) {
        mainPart = htmlPart;
    }

    struct mailimf_fields * fields;
    unsigned int i;
    struct mailmime * mime;

    fields = header()->createIMFFieldsAndFilterBcc(filterBcc);

    mime = mailmime_new_message_data(NULL);
    mailmime_set_imf_fields(mime, fields);

    if (mainPart != NULL) {
        add_attachment(mime, mainPart, MCUTF8(mBoundaryPrefix));
    }

    if (attachments() != NULL) {
        for(i = 0 ; i < attachments()->count() ; i ++) {
            Attachment * attachment;
            struct mailmime * submime;

            attachment = (Attachment *) attachments()->objectAtIndex(i);
            submime = mime_from_attachment(attachment);
            add_attachment(mime, submime, MCUTF8(mBoundaryPrefix));
        }
    }
    
    str = mmap_string_new("");
    col = 0;
    mailmime_write_mem(str, &col, mime);
    data = Data::dataWithBytes(str->str, (unsigned int) str->len);
    mmap_string_free(str);
    mailmime_free(mime);

    return data;
}

Data * MessageBuilder::data()
{
    return dataAndFilterBcc(false);
}

String * MessageBuilder::htmlRendering(HTMLRendererTemplateCallback * htmlCallback)
{
    MessageParser * message = MessageParser::messageParserWithData(data());
    return message->htmlRendering(htmlCallback);
}

String * MessageBuilder::htmlBodyRendering()
{
    MessageParser * message = MessageParser::messageParserWithData(data());
    return message->htmlBodyRendering();
}

String * MessageBuilder::plainTextRendering()
{
    MessageParser * message = MessageParser::messageParserWithData(data());
    return message->plainTextRendering();
}

String * MessageBuilder::plainTextBodyRendering(bool stripWhitespace)
{
    MessageParser * message = MessageParser::messageParserWithData(data());
    return message->plainTextBodyRendering(stripWhitespace);
}