Page 1 of 2 12 LastLast
Results 1 to 15 of 24
  1. #1
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Email pdf (2003)

    I'm trying to email a .pdf attachment from within Access. I openly admit and confess that I "snatched" this code (attached) from another post (my own no less), and made a few minor modifications. I'm not getting any error msgs, but it's not sending the email either. I'm using pdf995 and the report is opening in a "save to" window. Unfortunately, I no longer have the db from my earlier post, so I can't look to see what else might have been used there. Any help greatly appreciated.
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  2. #2
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Email pdf (2003)

    Associated with pdf995 you can install pdfedit. This adds functionality, including automatic saving of pdf files to a designated folder and filename.
    This will eliminate the Save As dialog.

    I would also add some code to allow the pdf creation to finish before moving on.

    I have used Call sSleep(2000) to wait 2 seconds.

    which requires this;

    Private Declare Sub sapiSleep Lib "kernel32" _
    Alias "Sleep" _
    (ByVal dwMilliseconds As Long)

    Sub sSleep(lngMilliSec As Long)
    If lngMilliSec > 0 Then
    Call sapiSleep(lngMilliSec)
    End If
    End Sub
    Regards
    John



  3. #3
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Email pdf (2003)

    I'm not sure I follow John. I do have pdfEdit, and use it all day to create documents. The current setting is to "Save As", the other options are for a designated folder or to the default My Documents. Are you saying that I need to change pdfEdit settings each time I use it? I've played with those settings, but it does nothing to get access to send the email via Outlook. I'm lost.
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  4. #4
    4 Star Lounger
    Join Date
    Dec 2002
    Location
    Kitchener, Ontario, Canada
    Posts
    421
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Email pdf (2003)

    Consider using Stephan Lebans free Report to PDF. It does everything for you and is self-contained. I will try to post some code for you later today as I just did this in another context a couple of months ago.

  5. #5
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Email pdf (2003)

    In an attempt to bring some clarity here; I have no problem generating the report in .pdf. I just stepped through the code and everything "seems" to be correct - but OL is not doing its part. The report is being generated and saved in My Documents (which I have no interest in, and in fact will become burdensome). I only want to send the report via Outlook, not "save" or "print" it.

    This is really frustrating because I know I had this working in another db, but don't know what I've done differently here <img src=/S/brickwall.gif border=0 alt=brickwall width=25 height=15>
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Email pdf (2003)

    Your code specifies that the file cdf995OutputrptWOAssign.pdf should be attached:

    strAttachment = "cdf995OutputrptWOAssign.pdf"

    If pdf995 saves the output to My Documents, as mentioned in your latest reply, Outlook obviously won't be able to find the file.

  7. #7
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Email pdf (2003)

    <img src=/S/drop.gif border=0 alt=drop width=23 height=23> . . .I'm lost. pdfEdit requires me to select one of the options shown in the pic, so isn't it always going to save it "somewhere"? I was feeling pretty confident that this was going to work because I know it worked in the other db - I don't know what was done differently there. If the doc gets saved (anywhere) it's going to cause a problem because that folder is going to get quite large in short order.

    Ha-ha, "obvious" to you maybe. I'm still trying to find the "Any" key!
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Email pdf (2003)

    You can delete the file using

    Kill "path+filename"

    after the e-mail has been sent.

  9. #9
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Email pdf (2003)

    I'd like to "kill" the whole thing right now! <img src=/S/burnup.gif border=0 alt=burnup width=31 height=31>
    I haven't even gotten to "after the email has been sent" stage yet.
    Let me see if I can strip this monster down. . .
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  10. #10
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts

    Re: Email pdf (2003)

    I think the "Save As" dialog is causing a problem because the VBA code does not stop executing while you Save the pdf. So I use the "Save all Documents with the same filename" option to avoid the Save As dialog.

    I agree with the suggestion that you use Stephan Lebans "Report to PDF" - i have recently started using that for this purpose and it works very well.

    To test your code can you just run the function that sends the email , using a pdf that already exists?
    Attached Images Attached Images
    Regards
    John



  11. #11
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Email pdf (2003)

    Bryan sent me a stripped down copy of the database. I have reduced it further and attach it here, with two small modifications:
    - I restored code to set object variables to Nothing at the end.
    - I restored the message box to display an error message if necessary.
    The problem is almost certainly that the file is not found. John has already suggested a solution for that.
    Attached Files Attached Files

  12. #12
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Email pdf (2003)

    Thanks for the help John!
    I changed the settings in pdfEdit to your suggestion and still have the issue of the file not being found. I'm checking out "Report to pdf" now.
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  13. #13
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Email pdf (2003)

    Have you checked exactly which filename pdf995 uses if you select the setting to save all PDF documents to the same filename?

  14. #14
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Email pdf (2003)

    Hans:
    Thanks for the help getting the db cut down, and the improvement in the code!
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

  15. #15
    5 Star Lounger bfxtrfcmgr's Avatar
    Join Date
    Aug 2002
    Location
    Fresno, California, USA
    Posts
    995
    Thanks
    12
    Thanked 0 Times in 0 Posts

    Re: Email pdf (2003)

    Hans:

    You just get to select any ol' folder you want (I guess). You then name it whatever you want.
    Bryan,
    Not the smartest critter on the glacier. . .
    . . .but I'm persistent (does that count?)

Page 1 of 2 12 LastLast

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •