On 17/7/00 2:40 AM, Raymond E. Griffith wrote:

> on 7/16/2000 1:11 PM, andu <[EMAIL PROTECTED]> tried to help me with my
> problem below:
> 
>> 
>>> I am trying to send an attachment file with the mcmail.mc file. So far, this
>>> is what I have done:
>>> 
>>> I put a field "theAttachment" into the card. The script is from the button
>>> "Send", with my addition clearly marked.
>>> 
>>> It does something, but it doesn't place it as an attachment, but as a part
>>> of the body text.
>>> 
>>> 
>>> # construct email header
>>> put "" into mailraw
>>> put "From: "& fld "mailfrom" & crlf after mailraw
>>> put "Date: "& mimedate() & crlf after mailraw
>>> put "Content-Type: text/plain; charset=us-ascii"& crlf after mailraw

You have to change the above line to something like:
put "Content-Type: multipart/mixed; boundary="& quote &\
    "TheMailBoundary"& quote & crlf after mailraw

>>> put "MIME-Version: 1.0"& crlf after mailraw
>>> put "Message-Id: <"& the seconds &"-"& the ticks &"@MetaCardSMTP>" & crlf
>>> after mailraw
>>> put "To: "& fld "to" & crlf after mailraw
>>> if fld "cc" <> "" then
>>> put "CC: "& fld "cc" & crlf after mailraw
>>> end if
>>> put "Subject: "& fld "subject" & crlf after mailraw
>>> put crlf & fld "body" after mailraw

Add the following here into the body:
put "--TheMailBoundary"& crlf &\
    "Content-Type: text/plain; charset=us-ascii"& crlf & crlf after mailraw

You may continue with your normal text mail body.

And finally add the following for your attachment:
# the attachment header
put "--TheMailBoundary"& crlf &\
    "Content-Type: application/base64; charset=us-ascii"& crlf &\
    "Content-Disposition: attachment; filename="& quote & \
    theAttachmentName & quote & crlf &\
   "Content-Transfer-Encoding: base64"& crlf & crlf after mailraw
# the attachment base64 code
put base64Encode(theattachment) & crlf after mailraw
# closing the email
put "--TheMailBoundary--" after mailraw
  
>>> -- ** MY ADDITION
>>> if fld "theAttachment" is not empty then
>>> put fld "theAttachment" into theAttachmentName
>> 
>> Try 
>> put url "binfile:" &  theAttachmentName into theattachment
>> put crlf & "Content-Type: application/base64; name=" & quote & \
>> theAttachmentName & quote after mailraw
>> put crlf & crlf & base64Encode(theattachment) after mailraw
>> 
> 
> I tried it. Still doesn't work. It does do something different, though (I'm
> not sure exactly why...). It seems to encode the name, but not the file.

The point here is to create a multipart MIME mail. If you refuse to read RFC
document, you can just grab a sample source of email with attachment.
Note that used of static "TheMailBoundary" here wasn't a good idea, you
should change it to a random generated string.

I have tried the code, so be careful.
Hope this helps.

Regards,
LiangTyan Fui


> But thanks. Still working on it. Any other suggestions?
> 
>>> put "binfile:" & theAttachmentName into theattachment
>>> put crlf & "Content-Type: application/base64; name=" & quote &
>>> theattachment & quote after mailraw
>>> put crlf & crlf & base64Encode(url theAttachment) after mailraw
>>> end if
>>> --
>>> 
>>> 
>>> # socket implementation, talking to smtp
>>> smtpsend fld "smtpserver",fld "mailfrom",validEmailList,mailraw
>>> end composemail
>>> 
>>> 
>>> --------------
>>> 
>>> I sent the file (a MetaCard file) to myself. I copied and pasted the encoded
>>> data in my email into a MC field. A button has the following script:
>>> 
>>> on mouseUp
>>> ask file "What file to save to?"
>>> put it into thefileName
>>> put base64Decode(field "thebinfile") into URL thefileName
>>> end mouseUp
>>> 
>>> But now, when I attempt to open the file (type into the message box "Answer
>>> file "?"; open it), I get the message "stack was corrupted by a non-binary
>>> file transfer"
>>> 
>>> -------------
>>> 
>>> So, any suggestions? I really *need* to be able to send file attachments
>>> with this MCmail protocol. I am building an app that will generate a MC
>>> stack, then email it to the appropriate person.
>>> 
> Thanks for your help,
> 
> Raymond


Archives: http://www.mail-archive.com/metacard%40lists.best.com/
Info: http://www.xworlds.com/metacard/mailinglist.htm
Please send bug reports to <[EMAIL PROTECTED]>, not this list.

Reply via email to