Subject: 0 byte attachments (was mail attachments)

From: "Joel Park" <[email-masked]>
Date: Thu, 4 May 2000 15:15:31 -0400

Further to my previous message, I am sending the message and adding the
attachment, however, the message is being received with a 0 byte attachment.
The steps taken to add the attachments are similar to the way PINE is doing
it:

First part is TYPETEXT.
All other parts for the attachments are added as TYPEOTHER with encoding set
to ENCBINARY.

It is to my understanding that smtp_mail() will automagically base64 encode
the attachments. Please advise if you have any inkling as to what I am
overlooking.

Thanks in advance,

-- 
------------------------------------------------------------------
 For information about this mailing list, and its archives, see: 
 http://www.washington.edu/imap/c-client-list.html
------------------------------------------------------------------

---

From: Mike Trank <[email-masked]>
Date: Thu, 4 May 2000 13:46:06 -0600 (CST)

> All other parts for the attachments are added as TYPEOTHER with encoding set

Joel, here is how I do it, hope this helps:

       mybody->type = TYPEMULTIPART;
        mybody->encoding = ENCOTHER;

        part1 = mail_newbody_part();
        part1->body.type = TYPETEXT;
        part1->body.encoding = ENC7BIT;
        part1->body.id = NIL;
        part1->body.description = NIL;
        part1->body.contents.text.data = voicegramtext;
        part1->body.contents.text.size = 11;

        part2 = mail_newbody_part();
        part2->body.type = TYPEAUDIO;
        part2->body.subtype = "X-WAV";
        part2->body.encoding = ENCBINARY;
        part2->body.id = NIL;
        part2->body.description = "Voicegram";

        part2->body.disposition.type = "attachment";
        bodyparam = mail_newbody_parameter();
        bodyparam->attribute = "filename";
        bodyparam->value = "Voicegram.WAV";
        bodyparam->next = NIL;
        part2->body.disposition.parameter = bodyparam;

        part2->body.contents.text.data = voicegram;
        part2->body.contents.text.size = voicegramsize;
        part2->body.size.bytes = voicegramsize;
        part2->next = NIL;

        part1->next = part2;

        mybody->nested.part = part1;

        strcpy(mysmtphost, smtphost);
        p = mysmtphost;             
        syslog(LOGPRI, "Opening SMTP stream.\n");
        mysmtp = (SENDSTREAM *)smtp_open_full(NIL, &p, "smtp", 25, NIL);

        syslog(LOGPRI, "Sending voicegram via SMTP.\n");
        r = smtp_mail(mysmtp, "MAIL", myenv, mybody);
        syslog(LOGPRI, "Message sent.\n");

        smtp_close(mysmtp);
        syslog(LOGPRI, "SMTP stream closed.\n");