Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    bobandtom is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    12

    attaching files to an email via a MACRO

    I am not even sure if what I am looking for is possible but here goes. I need a MACRO that will allow me to select a customer from a form, create an email message, pluck the email address from a table and attach multiple zipped files to the message.


    To add to the difficulty level, the file name of the zipped file contains the name of the customer.

    For instance, it might look like: 000020876-427-BBQ.zip. I might have several files that contain the BBQ. All files with BBQ would need to be attached to the email

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    I think this requires VBA, not macro.

    Fairly common topic. There are threads in this forum that provide sample code. Here is one https://www.accessforums.net/program...ort-30233.html
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    bobandtom is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    12
    I am not trying to send a report, but a group of zipped files. Would the same process apply?

  4. #4
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Quote Originally Posted by bobandtom View Post
    I am not trying to send a report, but a group of zipped files. Would the same process apply?
    The code in post #1 addresses adding attachments to the email.

    Code:
    'MyMail.Attachments.Add "c:myfile.txt", olByValue, 1, "My Displayname"
    Dim MyQuery As QueryDef
    Set MyQuery = CurrentDb.QueryDefs("ReportSource")
    MyQuery.SQL = "select * from emails "
    MyQuery.Close
    MyMail.Send

  5. #5
    bobandtom is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    12
    How do I get ACCESS to select the files that I want to add?

  6. #6
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    This is the line that adds the attachment.

    .Attachments.Add "c:myfile.txt"

    You would insert the file path within the quotes.
    If you can get .Send to work adding an attachment should not be a large hassle.

  7. #7
    bobandtom is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    12
    I need a MACRO that will allow me to select a customer from a form, create an email message, pluck the email address from a table and attach multiple zipped files to the message.
    To add to the difficulty level, the file name of the zipped file contains the name of the customer.

    For instance, it might look like: 000020876-427-BBQ.zip. I might have several files that contain the BBQ. All files with BBQ would need to be attached to the emai

  8. #8
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    What is a macro?

  9. #9
    bobandtom is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    12
    my bad

    scratch "a MACRO"
    and insert "VBA code"

  10. #10
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    The example code in the link provides basics for sending an email with attachments, doesn't have to be a report, can be whatever file you want.

    To attach multiple files, need code that will cycle through a folder and look for specified file name structure. Here is an example of looping code that adds file name to a listbox. In your case, you would instead attach to email only files that match name mask. http://www.allenbrowne.com/ser-59.html This has also been presented in other threads in this forum.

    Tricky part is figuring out the name mask for your files and setting the folder path.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  11. #11
    bobandtom is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    12
    I will give this a try and see if I understand it. Truth is, I am way over my head at this level with ACCESS. Any help would be appreciated.

    thanks

  12. #12
    bobandtom is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    12
    this link you provided states that it is for serious users. When it comes to Access and VBA I am not a serious user. I have been given a task and I need serious help. thanks

    Microsoft Access Tips for Serious Users


  13. #13
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Why did you accept the task if it is causing you to be in over your head? You will need to start at the beginning. Why don't you try sending one email without any attachments first and then build onto that?


    You can start with the code linked in post #1. Right now, all I am hearing is that you are in over your head. Maybe if you get your feet wet you will have a question where the answer is not something that is over your head.

  14. #14
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Most of us contributing suggestions are volunteers and don't have time or desire to build a full-blown app for someone. We have offered help by directing you to tools that just need to be adapted to your circumstances. Without intimate familiarity of your business model and data structure, we can't tailor code. You must attempt code and when encounter specific issue, post question for analysis. If this is a task you want to accomplish with Access, and you are required to develop and maintain it, then you must be a serious user. You can either learn the means to accomplish or pay a professional developer and then deal with the consequences after the developer goes away and something needs fixing but you don't have the knowledge to do so. If you want programming to automate database tasks, then need strong knowledge base in relational database principles, programming concepts, VBA language, and Access functionality. Take a class, study books, hire a tutor. Interaction in forum is inadequate for basic learning.

    Start with small steps. Get one piece of code working. First, just get sending an email without attachment to work (send to yourself for testing purposes). Then work in an attachment. Then work in the file looping for multiple attachments. It's not going to happen all in one day.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  15. #15
    bobandtom is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    12
    it was never a matter of "accepting" the task.

    I do appreciate your time and patience. Have a good life.

Page 1 of 2 12 LastLast
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Size concern with attaching files.
    By chrisfl in forum Access
    Replies: 2
    Last Post: 04-17-2013, 10:20 AM
  2. Replies: 31
    Last Post: 08-15-2012, 03:33 PM
  3. Import multiple Text files with a Macro
    By ArchMap in forum Access
    Replies: 3
    Last Post: 07-01-2011, 04:56 PM
  4. Attaching Files
    By jlclark4 in forum Forms
    Replies: 7
    Last Post: 01-20-2011, 03:01 PM
  5. Macro for Email Wizard Using the Access Runtime?
    By MFriend in forum Programming
    Replies: 1
    Last Post: 07-12-2010, 04:52 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums