Page 2 of 2 FirstFirst 12
Results 16 to 23 of 23
  1. #16
    bobandtom is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    12
    I have gotten this far with the to attach zip files to an email. I can hard code the name of a file into the code and it will add the zip file to the email but when I change the code as displayed so that the file that I select in a list box (list87 in this case) will be added, nothing happens.


    [code]Private Sub cmdEmail_Click()

    Dim olApp As Outlook.Application
    Dim olNS As Outlook.namespace
    Dim olFolder As Outlook.MAPIFolder
    Dim olMailItem As Outlook.MailItem
    Dim strGetFilePath As String
    Dim strGetFileName As String
    Dim Filename
    Filename = Me.List87
    Dim strBody As String


    strGetFilePath = "D:\EDPS\PRODUCTION\SEND\*.zip"
    strGetFileName = Dir("D:\EDPS\PRODUCTION\SEND\*.zip")
    Set olApp = CreateObject("Outlook.Application")
    Set olNS = olApp.GetNamespace("MAPI")
    Set olFolder = olNS.GetDefaultFolder(olFolderInbox)
    Set olMailItem = olFolder.items.Add("IPM.Note")
    strBody = Me.txtBody
    With olMailItem
    .Subject = lstEmail.Column(1) + "EDS Reports PHISECURE"
    .To = Me.lstEmail.Column(2)
    .body = strBody
    .Display
    .Attachments.Add ("D:\EDPS\PRODUCTION\SEND\" & Filename)
    End With

    Set olApp = Nothing
    Set olNS = Nothing
    Set olFolder = Nothing
    Set olMailItem = Nothing



    End Sub
    [code]

  2. #17
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Have you been able to attach and send one email with one attachment? You can automate the entire process of searching a folder and grabbing all files of a specifc type/format. Set aside your list box for the moment. Start with something like this....

    At the begining of your email procedure/Code declare a string that holds only the filename.

    Code:
    dim strFileName as string
    strFileName = "TestFile"

    with this you can place a test zip file named "TestFile" in the following path
    Code:
    dim strPath as string
    strPath = "\\ServerName\Folder\" & strFileName & ".zip"
    Now you are ready to send the one file. It is importatant that we know where you are in the process. So be sure to test this out.

    Instead of
    .Attachments.Add ("D:\EDPS\PRODUCTION\SEND\" & Filename)

    you can just place the string in there. Reason being is you can use the string twice. Once to get all of hte files in the directory and again to send the email.
    .Attachments.Add (strPath)

  3. #18
    bobandtom is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    12
    I replaced the line -
    .Attachments.Add ("D:\EDPS\PRODUCTION\SEND\" & Filename)

    with -
    .Attachments.Add ("D:\EDPS\PRODUCTION\SEND\PHS1.zip")

    And it does attach that file to the email.

  4. #19
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Is that something you were not able to accomplish before?

  5. #20
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    Your list box should function with this this.

    .Attachments.Add ("D:\EDPS\PRODUCTION\SEND\" & Filename & ".zip")

    The difficult part of looping through your file names is what becomes difficult. There are some things you will need to observe/understand first.

  6. #21
    bobandtom is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    12
    that I was always able to do. What I cannot do is select from a list and have the code attach a file.

  7. #22
    bobandtom is offline Novice
    Windows XP Access 2007
    Join Date
    Oct 2013
    Posts
    12
    I will work on that and get back to you. Thanks.

  8. #23
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    It has been a while since I reviewed this thread. What I can offer at present is, have your list box assign the appropriate value to Filename

    With that you will have the beginning of your ultimate goal. You email .Send will be associated with a dynamic .Attach

Page 2 of 2 FirstFirst 12
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