+ Reply to Thread
Results 1 to 5 of 5

Attaching PDFs in a folder to an email.

  1. #1
    Registered User
    Join Date
    07-25-2012
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    16

    Attaching PDFs in a folder to an email.

    Hi.

    I am struggling with his and I am wondering if anyone here would be able to help me. My projects getting a lot more complicated than I imagined.

    Basically in my project PDFs get saved in a folder c:\orders\ordersnew
    The idea is once there is a bunch of them I will attach them all to an email, then once they're sent i will move them to a new folder c:\orders\ordersent

    So what I am trying to achieve.

    A variable that collects how many PDFs are in the folder c:\orders\ordersnews (So in a cell I can write you have x orders to still send)

    Then clicking a button, it attaches all the PDF files in this folder to an email (doesn't send just attaches it and the new email opens in outlook)
    Then all the pdf files that are in c:\orders\ordersnew get moved to c:\orders\sent

    Buttons and all that I can handle myself. I have no idea on how to write the code or the best way to read howany PDFs are in a folder, attach them all to one email, and move them to another folder.

    Thanks a million for any help, much appreciated
    Last edited by yeahyeahyeah; 08-02-2012 at 06:13 AM.

  2. #2
    Valued Forum Contributor
    Join Date
    05-21-2009
    Location
    Great Britain
    MS-Off Ver
    Excel 2003
    Posts
    550

    Re: Attaching PDFs in a folder to an email.

    See Dir function for counting files in a folder - use a Dir file loop, which is common VBA code with many examples available.
    Use Name statement to move files. Search for Ron de Bruin email for adding attachments - you haven't said what your email client is.
    Post responsibly. Search for excelforum.com

  3. #3
    Registered User
    Join Date
    07-25-2012
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Attaching PDFs in a folder to an email.

    I am using outlook. I have already used some of rons code to convert cells to HTML then add them to the email body. That works well. I would use that again in this part to add predetermined text to te body of the email.

    Because the files in the folder will always have different names (the only common theme is they will all be PDF's, do I need to somehow get the names of the files to attach them and move them.

    I'll read up on the name and dir statements

    Thanks for your help

  4. #4
    Registered User
    Join Date
    07-25-2012
    Location
    australia
    MS-Off Ver
    Excel 2007
    Posts
    16

    Re: Attaching PDFs in a folder to an email.

    Ok so I have managed to count the number of PDF files and I have managed to sort out the moving of the PDF files.

    I can't seem to figure out how to attach the PDF files in an email. I can read the PDF files in a loop. The problem I'm expecting to get, is if I attach the file to an email in the loop it will attach 1 file per email.

    There could be twenty files there, and I need them to be all attached to 1 email

    Would I need to add each file to a string variable in the loop? That could potentially be a lot of variables

    ---------- Post added 08-03-2012 at 01:11 AM ---------- Previous post was 08-02-2012 at 11:57 PM ----------

    Problem solved chippy. Thanks for steering me in the right path

    I got the file names in a loop, then during the loop I stored them in sheet 6 a column in sequential cells.

    Then when attaching them to the email using a for command I went through the cells and used each cell value as the file path and name.
    Last edited by yeahyeahyeah; 08-02-2012 at 12:00 PM.

  5. #5
    Forum Expert Cutter's Avatar
    Join Date
    05-24-2004
    Location
    Ontario,Canada
    MS-Off Ver
    Excel 2010
    Posts
    6,451

    Re: Attaching PDFs in a folder to an email.

    @ yeahyeahyeah

    Based on your last post it seems that you are satisfied with the solution(s) you've received but you haven't marked your thread as SOLVED. I'll do that for you now but please keep in mind for your future threads that Rule #9 requires you to do that yourself. If your problem has not been solved you can use Thread Tools (located above your first post) and choose "Mark this thread as unsolved".
    Thanks.

    Also, as a new member of the forum, you may not be aware that you can thank those who have helped you by clicking the small star icon located in the lower left corner of the post in which the help was given. By doing so you can add to the reputation(s) of those who helped.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1