PC Review


Reply
Thread Tools Rate Thread

code to attach files

 
 
=?Utf-8?B?Q2hhZA==?=
Guest
Posts: n/a
 
      20th Feb 2007
I have code that generates an email and attaches specific files. I would
like to know if there is VBA code to be able to attach ALL files within a
specific folder, not just one specific file. Kind of like a "select all"
within a folder that attaches all selected items to an email. Any thoughts?
Thanks in advance.

-Chad
 
Reply With Quote
 
 
 
 
ed@HelpExcel.com
Guest
Posts: n/a
 
      20th Feb 2007
Chad,

You can navigate through files in a directory using the DIR command.
I recently blogged about it. It should point you in the right
direction regarding attaching all the files in one directory.

Regards,
Eddie
http://HelpExcel.com


 
Reply With Quote
 
=?Utf-8?B?SkxHV2hpeg==?=
Guest
Posts: n/a
 
      20th Feb 2007
See if you can find what you need on Ron de Bruin's site:

http://www.rondebruin.nl/sendmail.htm

"Chad" wrote:

> I have code that generates an email and attaches specific files. I would
> like to know if there is VBA code to be able to attach ALL files within a
> specific folder, not just one specific file. Kind of like a "select all"
> within a folder that attaches all selected items to an email. Any thoughts?
> Thanks in advance.
>
> -Chad

 
Reply With Quote
 
=?Utf-8?B?Q2hhZA==?=
Guest
Posts: n/a
 
      21st Feb 2007
thank you. this provided good insight and direction to my ultimate goal. i
was able to modify your DIR command code and incorporate adding attachments
to an email. lots of help. keep up the good work!

-chad

"(E-Mail Removed)" wrote:

> Chad,
>
> You can navigate through files in a directory using the DIR command.
> I recently blogged about it. It should point you in the right
> direction regarding attaching all the files in one directory.
>
> Regards,
> Eddie
> http://HelpExcel.com
>
>
>

 
Reply With Quote
 
=?Utf-8?B?U3RlZmk=?=
Guest
Posts: n/a
 
      10th Mar 2007
Hi Chad,

Could you share with me the code or the concept of sending an e-mail WITH
SPECIFIC FILES ATTACHED through VBA?

Thanks in advance!
Stefi


„Chad” ezt *rta:

> I have code that generates an email and attaches specific files. I would
> like to know if there is VBA code to be able to attach ALL files within a
> specific folder, not just one specific file. Kind of like a "select all"
> within a folder that attaches all selected items to an email. Any thoughts?
> Thanks in advance.
>
> -Chad

 
Reply With Quote
 
=?Utf-8?B?Q2hhZA==?=
Guest
Posts: n/a
 
      12th Mar 2007
here's a portion of the code i use:

'You must add a reference to the Microsoft outlook Library

Dim OutApp As Outlook.Application
Dim OutMail As Outlook.MailItem
Set OutApp = CreateObject("Outlook.Application")
Set OutMail = OutApp.CreateItem(olMailItem)
Dim strbody As String

strbody = "Email body text"

With OutMail
.To = "(E-Mail Removed)"
'.CC = ""
'.BCC = ""
subjectline = "test email
.Subject = subjectline
.Body = strbody
.Importance = olImportanceHigh
.ReadReceiptRequested = True
'define attachment
attachmentname = "c:\" 'adjust to your directory
Set myAttachments = OutMail.Attachments
myAttachments.Add attachmentname
.Send 'or use .Display to display the message prior to sending

End With

hope this helps,
-chad


"Stefi" wrote:

> Hi Chad,
>
> Could you share with me the code or the concept of sending an e-mail WITH
> SPECIFIC FILES ATTACHED through VBA?
>
> Thanks in advance!
> Stefi
>
>
> „Chad” ezt *rta:
>
> > I have code that generates an email and attaches specific files. I would
> > like to know if there is VBA code to be able to attach ALL files within a
> > specific folder, not just one specific file. Kind of like a "select all"
> > within a folder that attaches all selected items to an email. Any thoughts?
> > Thanks in advance.
> >
> > -Chad

 
Reply With Quote
 
=?Utf-8?B?U3RlZmk=?=
Guest
Posts: n/a
 
      12th Mar 2007
Thanks, Chad, it was a great help for me!
Stefi


„Chad” ezt *rta:

> here's a portion of the code i use:
>
> 'You must add a reference to the Microsoft outlook Library
>
> Dim OutApp As Outlook.Application
> Dim OutMail As Outlook.MailItem
> Set OutApp = CreateObject("Outlook.Application")
> Set OutMail = OutApp.CreateItem(olMailItem)
> Dim strbody As String
>
> strbody = "Email body text"
>
> With OutMail
> .To = "(E-Mail Removed)"
> '.CC = ""
> '.BCC = ""
> subjectline = "test email
> .Subject = subjectline
> .Body = strbody
> .Importance = olImportanceHigh
> .ReadReceiptRequested = True
> 'define attachment
> attachmentname = "c:\" 'adjust to your directory
> Set myAttachments = OutMail.Attachments
> myAttachments.Add attachmentname
> .Send 'or use .Display to display the message prior to sending
>
> End With
>
> hope this helps,
> -chad
>
>
> "Stefi" wrote:
>
> > Hi Chad,
> >
> > Could you share with me the code or the concept of sending an e-mail WITH
> > SPECIFIC FILES ATTACHED through VBA?
> >
> > Thanks in advance!
> > Stefi
> >
> >
> > „Chad” ezt *rta:
> >
> > > I have code that generates an email and attaches specific files. I would
> > > like to know if there is VBA code to be able to attach ALL files within a
> > > specific folder, not just one specific file. Kind of like a "select all"
> > > within a folder that attaches all selected items to an email. Any thoughts?
> > > Thanks in advance.
> > >
> > > -Chad

 
Reply With Quote
 
=?Utf-8?B?a2FsaWt3?=
Guest
Posts: n/a
 
      14th Apr 2007
Chad,
I am currently working on a program that allows the user to email the excel
document but I also need to attach supporting files with it (usually a word
document as well), however those documents change constantly so it will
easier to have the code grab the files than set up the code each time for
each document. I have created a folder where all the supporting documents
reside. Would you be willing to share the code, that allows you to loop
through the folder and attaches all the files, just like the "Select All" you
posted in the message. I saw the code for the DIR from the help excel
website but I was not able to modify it successfully to allow for it attach
all files, it looped correctly, when I ran the example as is. However my
modified code give me automation errors, when it ran. Any ideas or pointers
in the right direction will help. I am learning visual basic so I do
understand the concepts. Any help will be most appreciated.

Karen

"Chad" wrote:

> here's a portion of the code i use:
>
> 'You must add a reference to the Microsoft outlook Library
>
> Dim OutApp As Outlook.Application
> Dim OutMail As Outlook.MailItem
> Set OutApp = CreateObject("Outlook.Application")
> Set OutMail = OutApp.CreateItem(olMailItem)
> Dim strbody As String
>
> strbody = "Email body text"
>
> With OutMail
> .To = "(E-Mail Removed)"
> '.CC = ""
> '.BCC = ""
> subjectline = "test email
> .Subject = subjectline
> .Body = strbody
> .Importance = olImportanceHigh
> .ReadReceiptRequested = True
> 'define attachment
> attachmentname = "c:\" 'adjust to your directory
> Set myAttachments = OutMail.Attachments
> myAttachments.Add attachmentname
> .Send 'or use .Display to display the message prior to sending
>
> End With
>
> hope this helps,
> -chad
>
>
> "Stefi" wrote:
>
> > Hi Chad,
> >
> > Could you share with me the code or the concept of sending an e-mail WITH
> > SPECIFIC FILES ATTACHED through VBA?
> >
> > Thanks in advance!
> > Stefi
> >
> >
> > „Chad” ezt *rta:
> >
> > > I have code that generates an email and attaches specific files. I would
> > > like to know if there is VBA code to be able to attach ALL files within a
> > > specific folder, not just one specific file. Kind of like a "select all"
> > > within a folder that attaches all selected items to an email. Any thoughts?
> > > Thanks in advance.
> > >
> > > -Chad

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Attach code MAX Microsoft Excel Worksheet Functions 5 16th Mar 2009 11:11 PM
Attach VB Code to Form? =?Utf-8?B?Rw==?= Microsoft Outlook Form Programming 5 20th Aug 2007 08:45 PM
I want to attach word files or PDF files to an excel database =?Utf-8?B?RGlhbm5lIE11bnJv?= Microsoft Excel Misc 1 23rd Mar 2006 12:11 AM
Code to attach more than 1 document =?Utf-8?B?SmFz?= Microsoft Outlook VBA Programming 1 22nd Mar 2006 06:41 AM
Re: Attach code to a button Steve C. Orr, MCSD Microsoft ASP .NET 0 29th Jul 2003 07:40 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 09:12 PM.