473,473 Members | 2,025 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How do I attach multiple files to Mail?

5 New Member
I need a piece of code which could attach all the files stored in a folder.
The files in the folder can be *.xls, *.doc or *.pdf. I will be having only the path of the folder and file names in the folder would be dynamic.
Can anyone help me out?
Nov 12 '07 #1
9 3848
Tequilaman
44 New Member
What about calling an open file box for the path with verification on the file name extensions? In case you need you can disable attachments from different path as well. Still in that path you will let the user decide about attaching the file(s).

Or do you want to automate upload, sending etc.? - Using a batch lying in that path for the choice might still be an alternative.
Nov 12 '07 #2
rohithcs
5 New Member
What about calling an open file box for the path with verification on the file name extensions? In case you need you can disable attachments from different path as well. Still in that path you will let the user decide about attaching the file(s).

Or do you want to automate upload, sending etc.? - Using a batch lying in that path for the choice might still be an alternative

Thanks for your reply.
I want to automate the upload. The path of the folder is fixed. And I would like to attach all the files in the folder.

Could please help me out?
Nov 12 '07 #3
Tequilaman
44 New Member
I would just select by " *.* " in the path using the ancient DOS routine. - Hoping you don't use VISTA, in XP it still works.

For that you need to specify the path like " X:\tempor~1\*.* " - I have had some trouble with the long file (directory) names when transfering progs. Using 8 char should be better to keep it from crashing
Nov 12 '07 #4
Killer42
8,435 Recognized Expert Expert
I think to give any useable advice we need more detail about what you are doing now, in what version of VB. Selecting all the files in a folder in VB is very simple, but the details will vary a bit between versions. And presumably, attaching them to an e-mail will depend on how you are creating the e-mail.
Nov 13 '07 #5
rohithcs
5 New Member
I think to give any useable advice we need more detail about what you are doing now, in what version of VB. Selecting all the files in a folder in VB is very simple, but the details will vary a bit between versions. And presumably, attaching them to an e-mail will depend on how you are creating the e-mail.

Here is detail requirement.
Requirement: With cllck of a button. I would like to send a mail and attach the files in a particular folder.

Code:
Private Sub Form_Load()
Dim Olook As Object
Dim Omail As Object
Set Olook = CreateObject("Outlook.Application")
Set Omail = Olook.CreateItem(olMailItem)

MailBody = "Hi ,"
Mail1Body = " Find attached the documents ,"

Omail.To = "new@yahoo.co.in"
Omail.Subject = "Find documents "
Omail.Body = MailBody & vbCrLf & vbCrLf & Mail1Body & EndOfMail

Omail.Display:

Unload Me
End Sub


Problem:
with the above code i am able to compose the mail. I am not sure how to attach files to this mail.
Nov 13 '07 #6
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

Take a Look at this M$ Article:
Outlook Attachment

Regards
Veena
Nov 13 '07 #7
rohithcs
5 New Member
Hi,

Take a Look at this M$ Article:
Outlook Attachment

Regards
Veena
Thanks for your support.
I looked into the article in the mentioned link.
The code works fine, if you know the filename.

what if the filename keeps changing? (Although path remains the same)
Nov 13 '07 #8
QVeen72
1,445 Recognized Expert Top Contributor
Hi,

Place a "File List Box" on the Form, and Change the Path of that and Refresh it. FileListBox will be populated with all the Files in that Folder..
Loop through the List Items (as any Normal ListBox) and it should be done..

some thing like this :

Expand|Select|Wrap|Line Numbers
  1.   Dim MyFileName As String
  2.   Dim i As Integer
  3.   File1.Path = "C:\MyFolder"
  4.   File1.Refresh
  5.   For i = 0 To File1.ListCount-1
  6.       MyFileName = File1.Path & "\" & File1.List(i)
  7.       ' MyFile Name is the File Name in that Folder
  8.       ' Write Your Attachment Code here 
  9.   Next
  10.  

Regards
Veena
Nov 13 '07 #9
Killer42
8,435 Recognized Expert Expert
Since it looks as though you're using VB6, it's also quite simple to use the Dir() function to retrieve file names. For example, to read all the filenames in the folder Veena used...

Expand|Select|Wrap|Line Numbers
  1. Dim FileName As String
  2. FileName = Dir("C:\MyFolder") ' Find first matching file.
  3. Do While FileName <> ""
  4.   Debug.Print FileName
  5.   FileName = Dir ' No parameters. Just gets next match.
  6. Loop
The advantage of this is that it's quick and simple. It doesn't require a form, a control, or (as the FileSystemObject would) any extra references.
Nov 13 '07 #10

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: tabonni | last post by:
Hi I try to grab the checked files from HTML page and then send those PDF files as attachments. It can just send email, there are no PDF files attached. Can anybody point out my error? My...
1
by: bmcelhany | last post by:
I have a windows service that monitors a directory for newly created files. When one is found, an e-mail is generated and the new file is added as an attachment. In order to avoid trying to attach...
2
by: ohb | last post by:
Hello, Is it possible to parse a attach file in a email ? ohb
1
by: vijaygparikh | last post by:
HI i am writting a code for open default mail client and it works fine. i want to attach a file with the default mail client but file is not attached with "mailto:" option. If any one has idea...
0
by: sallysmedly | last post by:
Hi, I have a page where a user can browse for and attach 2 files to an email. The email works fine when I try to send a selected file from the server, but I have added in some script so that...
1
by: Jyo | last post by:
Hi All! I have problem regarding multiple file attachment. Can any one help regarding script like gmail provides for attach a file with remove link ? Also please note that this code should...
8
AmberJain
by: AmberJain | last post by:
I'm having an mail account on yahoo mail. I formatted my HDD 3 days ago and reinstalled windows XP professional SP2. My problem is that I'm unable to attach any files to any of outgoing mail in my...
66
by: happyse27 | last post by:
Hi All, my html code is sno 1) and perl code is sno 2). a) I tried to print $filename and it cant print out the value, only blank was displayed, and the file could not be uploaded. And it...
4
by: zamb | last post by:
am trying to do php mailing list but i have failed to attach files to it so that i can be able to send them as attachments with the message of the mail just like yahoo does. and my script for sending...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.