realbasic-nug
[Top] [All Lists]

Re: Sending PDF with SMTP Socket

To: REALbasic NUG <realbasic-nug at lists dot realsoftware dot com>
Subject: Re: Sending PDF with SMTP Socket
From: Jeff Ayling <jeff at wam dot net dot au>
Date: Sun, 1 Aug 2004 12:55:24 +1000
Delivered-to: realbasic-nug at lists dot realsoftware dot com
References: <8165CD28-E31B-11D8-BAD5-003065D61478 at implements dot be>

On 01/08/2004, at 4:00 AM, Yves Vindevogel wrote:

Hi,

I'm trying to send a PDF file as attachment with the SMTP Socket
I'm using the code from the Reference manual, with this extension, the "mime type"

  file = New EmailAttachment
  file.MIMEType = "application/x-pdf"

  file.loadFromFile GetFolderItem("040731uittreksel1.pdf")
  mail.attachments.append file //add file to attachments array

  SMTPSocket1.messages.append mail //add email to list of messages
  SMTPSocket1.SendMail //send message


When I receive the mail (I'm sending to myself to test), Adobe can't open it.
Says it was either corrupt or send with the wrong encoding.

What do I need to specify ?  What's the encoding of a PDF.
The document itself contains only a scanned file.

Regards
Yves




Rather than using loadfromfile, try this...

dim file as emailAttachment
dim mail as emailMessage
dim tin As TextInputStream

f=getfolderitem(pathtofile)
 file = new emailAttachment
  tin = f.OpenAsTextFile
  if tin <> Nil then
    file.MIMEType = "audio/mp4"
    file.MacCreator = f.MacCreator
    file.MacType = f.MacType
    file.Name = f.Name
    file.ContentEncoding = "base64"
    file.Data = EncodeBase64(tin.ReadAll, 76)
    tin.Close
  end if

  mail.attachments.append file


I believe that the EncodeBase64 is the area which will fix your probs,


Cheers


Jeff



_______________________________________________
Unsubscribe or switch delivery mode:
<http://www.realsoftware.com/support/listmanager/>

Search the archives of this list here:
<http://www.realsoftware.com/listarchives/lists.html>

<Prev in Thread] Current Thread [Next in Thread>