Page 1 of 1

Help attaching a pdf from speical folder path documents

Posted: Tue Oct 04, 2011 11:29 pm
by wolfkillshepard
Here I have code that prints a PDF from two cards elsewhere in the stack and saves it on the phone

Code: Select all

   put specialFolderPath("documents") & "/testpdf.pdf" into tPDFPath
   
   open printing to pdf tPDFPath
   if the result is "Cancel" then
      -- The user has cancelled printing
      #exit printCards
   else
            --Print the card into the printable area
      print card "PDFPrint1" of this stack into 0,0,575,800
      
      print break
      
      print card "PDFPrint2" of this stack into 0,0,575,800
   end if
   close printing
After the PDF is created I am trying to put it in as an attachment on the native email client. I have the email functioning and sending out a PDF but its not the file I am trying to attach. I know my code is wrong and I've spent hours tweaking it in many different ways to try and get that (specialFolderPath("documents") & "/testpdf.pdf") as an attachment. Here is that email code

Code: Select all

global gvAttachment

command attachToEmail pAttachmentText, pAttachmentName
    put specialFolderPath("documents") & "/testpdf.pdf" into gvAttachment["data"]
    put "testpdf.pdf" into gvAttachment["name"]
    put "pdf" into gvAttachment["type"]
end attachToEmail

On Mouseup
   attachToEmail
   
   --declare the variables that hold the information that is to be included in the e-mail
    local tSubject, tTo, tCCs, tBCCs, tBody
 
        --populate the e-mail variables
        put empty into lvLaunchString
        put "Appearance Release" into tSubject
        put "Akauble@metaxpert.com" into tTo
        put "Cspring@metaxpert.com" into tCCs
        put "Rzimmerle@metaxpert.com" into tBCCs
        put "This is your Appearance Release" into tBody
        --send the e-mail
        iphoneComposeHtmlMail tSubject, tTo, tCCs, tBCCs, tBody, gvAttachment

        --End Email
End MouseUp

I would really appreciate help, I've spent quite a bit of time try to get this to work.
Thanks!

Re: Help attaching a pdf from speical folder path documents

Posted: Wed Oct 05, 2011 7:35 am
by bn
Hi Wolf,
shouldn't

Code: Select all

 put specialFolderPath("documents") & "/testpdf.pdf" into gvAttachment["data"]
be

Code: Select all

 put specialFolderPath("documents") & "/testpdf.pdf" into gvAttachment["file"]
? "file" instead of "data"

according to the docs
• data – the binary data to attach to the email (not needed if file present)
• file – the filename of the file on disk to attach to the email (not needed if data present)
• type – the MIME-type of the data.
• name – the default name to use for the filename displayed in the email
I did not test this, it is just from the documentation.

Kind regards

Bernd

Re: Help attaching a pdf from speical folder path documents

Posted: Wed Oct 05, 2011 11:11 pm
by wolfkillshepard
I figured that out last night thanks dude!