+ Reply to Thread
Results 1 to 33 of 33

How to attach PDFs from desktop folder to various emails?

  1. #1
    Forum Contributor
    Join Date
    08-29-2006
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    314

    Red face How to attach PDFs from desktop folder to various emails?

    Hi all

    I have a folder on desktop called "CreditPdf" which has some pdf files saved in it and this is variable.

    I also have an excel sheet which has email addresses on Colum J which are unique to the ShortCodes on Column K.

    I like to attach PDFs in "H:\Desktop\CreditPDF" folder to the emails under the Colum J, if the Invoice Name matches with the PDFs in the "CreditPDF" folder. If it is same code under Colum K, I like one email with multiple attachments?

    is this possible?

    I attach a sample sheet and picture

    kind regards

    Stay home be safe!!
    Attached Images Attached Images
    Attached Files Attached Files
    Last edited by lapot; 04-13-2020 at 06:00 PM.

  2. #2
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to verious emails?

    So you already know how to send the emails, well once you have that then all you need is add attachment including the FULLPATH and Filename
    in the email code

    Please Login or Register  to view this content.
    ---
    Hans
    "IT" Always crosses your path!
    May the (vba) code be with you... if it isn't; start debugging!
    If you like my answer, Click the * below to say thank-you

  3. #3
    Forum Contributor
    Join Date
    08-29-2006
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: How to attach PDFs from desktop folder to verious emails?

    thanks for reply but i cant do multiple emails depending on different Client codes

  4. #4
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to verious emails?

    if it's multiple attachments then you have to create an array with the fullpath and filename in each item of that array.
    You have attached an xlsm file (which implies that it contains macros) but there are no macros.
    So what do you have ?
    And, how many attachments can it be? Varying from 1 to many?

  5. #5
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to verious emails?

    Take a look here. helped me very much.
    Enough samples and code samples
    http://www.rondebruin.nl/win/section1.htm

  6. #6
    Forum Contributor
    Join Date
    08-29-2006
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: How to attach PDFs from desktop folder to verious emails?

    Sorry I have now attached a macro on the sample which pulls all the PDFs into one email from the folder but I need PDFs attached to relevant Client Codes in separate emails.

  7. #7
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to various emails?

    I'll see and check tomorrow, past midnight now.

  8. #8
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to various emails?

    Okay, clear, I see what you've done, which is not really incorrect, only you need to select the file for each appropriate client.
    My approach would be have two macros, one to create the pdf's which can be run if the pdf is not already present.
    The other macro would be to process the email.
    Just to make sure I understand: you have duplicate clients and you want to send just one mail with all the attachments for that client. Correct?
    Or separate emails even if it's the same client per invoice?

  9. #9
    Forum Contributor
    Join Date
    08-29-2006
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    314
    I want to send just one mail with all the attachments for that client.Not separate email for each PDF. Is it possible?

    Many thanks

  10. #10
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to various emails?

    Yes, of course that's possible only you have to rethink your approach.
    This means that as you sample is now, it will be three emails and two of these have more than one attachment. Correct?

  11. #11
    Forum Contributor
    Join Date
    08-29-2006
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: How to attach PDFs from desktop folder to various emails?

    on this occasion yes but some times it can be 5 or 10 for same client code, it is variable.

  12. #12
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to various emails?

    Of course, but once you put it together it will work.
    But, have you thought of what you want to do after the message(s) have been sent?
    Like it is now the macro will resend the same message again when you run it again.
    You have not built in a status like mail sent is true or false

  13. #13
    Forum Contributor
    Join Date
    08-29-2006
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: How to attach PDFs from desktop folder to various emails?

    i will deal with that later, at the moment it just displays the email and i will chose send or not send.this is not a big issuer for me,.

    my main problem is i cant do the attachments for each client

  14. #14
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to various emails?

    Okay, will see what I can do to help you.

  15. #15
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to various emails?

    Well, you're code is IMHO a mess, and I don't feel like building it all up again in a logical way.
    First the paths and so are not accessible to me so I have to improvise and set other paths, which is no problem, but I'm not in for it.
    What I do want to say is that you can use your own code but you need to do it as follows:

    I don't know why you have With oEmailItem embedded into each other.
    I would make sure that you extract the unique list of Client names.
    once you have that you process each name and the the whole of column B.
    Inside that look you add the attachments with the client's invoice and when completed you can take the next one.
    that means the whole of column B in this case get processed three times.
    But, I noticed that the second occurrence or Radian is not equal to the one above, the second one has a space after the name, that is something to keep in mind when comparing strings, one with a space at the end is different from one with out it

    Another thing you can reduce the follwoing string:

    Please Login or Register  to view this content.
    to

    Please Login or Register  to view this content.

  16. #16
    Forum Contributor
    Join Date
    08-29-2006
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: How to attach PDFs from desktop folder to various emails?

    Hi mate

    thank you for your effort, I know the code is extra things that it shouldn't be there , you can avoid them. Signature is not an issue you can take it out from the code too.

    I need to create a filer on the Client code (Column K) each time it will bring up the word document links for that client (Column F) then created the PDF documents then save into the CreditPDF folder then attach to the email whatever in the folder then delete everting in the PDF folder.

    Then filter next Client code, create all the PDF documents for the filtered client code, attach again all to the email and delete all the PDFs from the folder so on …..

    does it make sense ?

    thank you in advance

  17. #17
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to various emails?

    It all makes sense but it's very unmanageable.
    You could consider like I said loop though a unique list, create the pdf(s) for that client and then mail, then process the next one.
    You could even use the temp folder since you're deleting the pdfs after mailing.
    Let me see if I can put the time in and at least give you the basic code so you can do your thing with your paths.

  18. #18
    Forum Contributor
    Join Date
    08-29-2006
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: How to attach PDFs from desktop folder to various emails?

    I really apricate mate if you could

  19. #19
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to various emails?

    I have not run the macro because I did not want to alter anything in the table.
    Give it a run and see what it does.
    So this is untested by me, just written out using part of your code and adding some of mine

    PS modified the attachment, missed a thing in the code.
    Attached Files Attached Files
    Last edited by Keebellah; 04-14-2020 at 01:29 PM. Reason: Modified attachment

  20. #20
    Forum Contributor
    Join Date
    08-29-2006
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: How to attach PDFs from desktop folder to various emails?

    I get this errorAttachment 672483

  21. #21
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to various emails?

    The attachment you included is invalid.

  22. #22
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to various emails?

    What's the exact error message?

  23. #23
    Forum Contributor
    Join Date
    08-29-2006
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: How to attach PDFs from desktop folder to various emails?

    please see the attachment

    thank you
    Attached Images Attached Images

  24. #24
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to various emails?

    Typo- how about typing the correct syntax.
    I said I could not test it.
    .Attachments
    I expected a little more initiative

  25. #25
    Forum Contributor
    Join Date
    08-29-2006
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: How to attach PDFs from desktop folder to various emails?

    Sorry it was my bad, it has been a long day, I must have overlooked the spelling. I corrected it but it did 3 times same email. I was watching inside the folder ,it wasn't putting just the relevant document inside the folder, it was putting all 5 document on each email with same subject and body.

    here is the screen shot
    Attached Images Attached Images

  26. #26
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to various emails?

    Like I said , it was just the code I wrote no testing possible without changing the content, I’ll pick it up later today and see what I can come up with to recreate your data
    Pity, troubleshooting takes time

  27. #27
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to various emails?

    Pls check if the file you’re using is the last one I updated it later the same day adding spme lined of code between the for each ci and the for each ring Clearing the str variables

  28. #28
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to various emails?

    This is the part that I mean:

    Please Login or Register  to view this content.
    I also see that the Hi ... refers to the wrong column, but that YOU can change too.
    Like I said, will see if I can modify the sample file with some fake word files and see what I can do.

  29. #29
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to various emails?

    Macro code needed several corrections due to lack of testing not detected:

    See screenshot of the result
    Paste this code replacing the macro in your file (just this one macro
    Please Login or Register  to view this content.
    Attached Images Attached Images

  30. #30
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to various emails?

    The body text formatting needs to be done correctly but that's a question of inserting the correct HTML tags in the strBody textstring

  31. #31
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to various emails?

    I placed the modified vba code in the sample with your file settings. Should work too.
    Also did something to the HTML text formatting and looks better
    Attached Files Attached Files

  32. #32
    Forum Contributor
    Join Date
    08-29-2006
    Location
    London
    MS-Off Ver
    Excel 2016
    Posts
    314

    Re: How to attach PDFs from desktop folder to various emails?

    Wow, what can I say !! you are a legend, if I was near you I would send you a bottle of drink. This is amazing. It works perfectly.. I cant thank you enough..

  33. #33
    Forum Expert Keebellah's Avatar
    Join Date
    01-12-2014
    Location
    The Netherlands
    MS-Off Ver
    Office 2021 (Windows)
    Posts
    7,900

    Re: How to attach PDFs from desktop folder to various emails?

    Glad to have been able to help and to hear it works as planned.
    Don't forget to mark the post as solved.

    Cheers,

    Happy coding

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. [SOLVED] copy file(s) from folder and / or subfolders to desktop folder
    By skyping in forum Excel Programming / VBA / Macros
    Replies: 19
    Last Post: 03-04-2020, 06:43 AM
  2. [SOLVED] Macro for saving sheet as PDF to desktop and attach to email
    By Alan3770 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-05-2018, 07:43 PM
  3. [SOLVED] Create emails and attach several attachments
    By Pederpa in forum Excel Programming / VBA / Macros
    Replies: 8
    Last Post: 09-26-2017, 03:44 AM
  4. [SOLVED] Macro to attach a file to out going emails?
    By THTABE in forum Excel Programming / VBA / Macros
    Replies: 9
    Last Post: 11-21-2016, 09:48 AM
  5. [SOLVED] Loop Through Folder, Create Emails with Sub Folder Names in Subject, Attach files in sub
    By Rschwar23 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 06-30-2015, 10:06 AM
  6. Copy all emails in outlook folder and paste them in similar system folder and ms access
    By Megatronixs in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 11-28-2014, 07:31 AM
  7. [SOLVED] Attaching PDFs in a folder to an email.
    By yeahyeahyeah in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-02-2012, 06:02 PM

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