Problem with mail attachements

Discussion in 'Visual Basic ( VB )' started by CFC 409, Apr 18, 2007.

  1. CFC 409

    CFC 409 New Member

    Joined:
    Apr 18, 2007
    Messages:
    1
    Likes Received:
    0
    Trophy Points:
    0
    Hi,

    I found this code in your site and I happy to use it.
    Code:


    Code:
    Dim objOutlookMsg As Object
    Set objOutlook = CreateObject("Outlook.Application")
    Set objOutlookMsg = objOutlook.CreateItem(0)
    With objOutlookMsg
       .To = "name@email.com"
       .Cc = "name@email.com"
       .Subject = "Hello World (one more time)..."
       .Body = "This is the body of message"
       .HTMLBody = "HTML version of message"
       .Attachments.Add ("f:\Test.txt")
       .Send 'Let´s go!
    Set objOutlookMsg = Nothing
    Set objOutlook = Nothing
    End Sub
    I need attach more than one file in the same mail. For example I need attach all text files that are in directory. I tried to use string:

    .Attachments.Add ("f:\Directory\*.txt")

    but it did not work. Could you help me.
    Thank you.
     
    Last edited by a moderator: Apr 18, 2007
  2. pradeep

    pradeep Team Leader

    Joined:
    Apr 4, 2005
    Messages:
    1,645
    Likes Received:
    87
    Trophy Points:
    0
    Occupation:
    Programmer
    Location:
    Kolkata, India
    Home Page:
    http://blog.pradeep.net.in
    You'll have to loop through the file list in a directory and add the files individually!
    Use the filesystem object.
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice