Loop Attachment (once again)

Status
Not open for further replies.
R

RGFu

Hello people,

Here is a question: I need a macro that will be able to create a new message

and add an attachment per each new message and loop through a folder. The

reason for that is attachments should be of specific size not less or more of

500 KB each and therefore I can't add all of them into one email. And there

will about 50 messages, maybe more later. It will be continuing (at least it

looks like so for now). Anyone can help me with it? Thanks in advance

Dan

PS: At least, if you know any recommendations of where I can find similar

written code.
 
K

Ken Slovak - [MVP - Outlook]

What version of Outlook. This is supposed to run as an Outlook VBA macro?

What do you mean by "loop through a folder"? What kind of folder, loop and

do what?

I don't know what 50 messages has to do with it, what is different about

each of those 50 messages? How do you want the code to handle those 50

messages, is it different for each one? How?

Is this macro supposed to run on demand or automatically?

There are lots of Outlook code samples at www.outlookcode.com, but no one

can be much more specific until you clearly explain what you need and what

you want to accomplish. That's most likely why no one has been answering

your posts, the requirements aren't clearly explained.

"Dan" <Dan> wrote in message

news:6DB613F5-E796-428C-97EC-3580280B07C6@microsoft.com...
> Hello people,
> Here is a question: I need a macro that will be able to create a new
> message
> and add an attachment per each new message and loop through a folder. The
> reason for that is attachments should be of specific size not less or more
> of
> 500 KB each and therefore I can't add all of them into one email. And
> there
> will about 50 messages, maybe more later. It will be continuing (at least
> it
> looks like so for now). Anyone can help me with it? Thanks in advance
> Dan
> PS: At least, if you know any recommendations of where I can find similar
> written code.
 
R

RGFu

Hi Ken,

Sorry about the confusion - I am using MS Outlook 2007. The issue about the

folder and 50 messages, I need to send some files to friend of mine which is

about 50 MB but provider doesn't let emails through that have attachments

that are more 500 KB, therefore I had split them. Now I have 100 files and I

will have to create an email for each file. Like 1st email and attache 1st

file, and then create 2nd email and attach 2nd file and so one until I am

done attaching all 100 files (that is why I called it loop - do until finish

all files in a folder). It is a bit tiresome and that is the reason I had

asked for help! Do you think there is anything available at Outlook

Programming-VBA community?

With best regards

Dan
 
K

Ken Slovak - [MVP - Outlook]

I don't think there's anything specific for something like that, if it was

me and I didn't own a Web site I'd just use one of those public sites where

you can post files for FTP downloads, or something like that. I'd also be

looking for a different ISP, that limitation is absurd.

You can use something like FileSystemObject to get at the folder and all

files in it. Then loop and iterate each file and add it as an attachment to

a mail item. Something like this I suppose, which would require a VBA

project reference for the MS Scripting Runtime (scrrun.dll):

Dim FSO As Scripting.FileSystemObject

Dim tFile As Scripting.File

Dim oFolder As Scripting.Folder

Dim sPath As String

Dim sTemp As String

Set FSO = CreateObject("Scripting.FileSystemObject")

sPath = "C:\"

Set oFolder = FSO.GetFolder(sPath)

For Each tFile In oFolder.Files

sTemp = sPath & tFile.name

Set oMail = Application.CreateItem(olMailItem)

oMail.Subject = "More files"

Set oRecip = oMail.Recipients.Add("joe@test.com")

oRecip.Resolve

oMail.Attachments.Add(sTemp)

oMail.Send

Next

"Dan" <Dan> wrote in message

news:D1E45EC6-011A-4829-B99C-CE13AD794EDC@microsoft.com...
> Hi Ken,
> Sorry about the confusion - I am using MS Outlook 2007. The issue about
> the
> folder and 50 messages, I need to send some files to friend of mine which
> is
> about 50 MB but provider doesn't let emails through that have attachments
> that are more 500 KB, therefore I had split them. Now I have 100 files and
> I
> will have to create an email for each file. Like 1st email and attache 1st
> file, and then create 2nd email and attach 2nd file and so one until I am
> done attaching all 100 files (that is why I called it loop - do until
> finish
> all files in a folder). It is a bit tiresome and that is the reason I had
> asked for help! Do you think there is anything available at Outlook
> Programming-VBA community?

> With best regards
> Dan
 
R

RGFu

Thanks again, Ken! It worked just perfect. Unfortunately changing ISP would

not help, as the attachment size limitation issue is not in US, the ISP is in

Central Asia, the recipient's provider. And there are not many providers

available either in there. And FTP public sites are not available either.

Anyway, thanks again.

All the best

Dan.
 
C

Curt

signature & picture

Not familar with outlook VBA have used excel & word. Would like to build a

macro that will insert a signature & a picture on one stroke. I use a two

step method now only on forward or reply messages. If i create a new message

it will not allow me to insert signature & picture. Useing 2000 & xp

Any code I can work with will be appreciated.

Thanks
wrote:


> I don't think there's anything specific for something like that, if it was
> me and I didn't own a Web site I'd just use one of those public sites where
> you can post files for FTP downloads, or something like that. I'd also be
> looking for a different ISP, that limitation is absurd.

> You can use something like FileSystemObject to get at the folder and all
> files in it. Then loop and iterate each file and add it as an attachment to
> a mail item. Something like this I suppose, which would require a VBA
> project reference for the MS Scripting Runtime (scrrun.dll):

> Dim FSO As Scripting.FileSystemObject
> Dim tFile As Scripting.File
> Dim oFolder As Scripting.Folder
> Dim sPath As String
> Dim sTemp As String

> Set FSO = CreateObject("Scripting.FileSystemObject")
> sPath = "C:\"
> Set oFolder = FSO.GetFolder(sPath)
> For Each tFile In oFolder.Files
> sTemp = sPath & tFile.name

> Set oMail = Application.CreateItem(olMailItem)

> oMail.Subject = "More files"

> Set oRecip = oMail.Recipients.Add("joe@test.com")
> oRecip.Resolve

> oMail.Attachments.Add(sTemp)

> oMail.Send
> Next

> >

>

> "Dan" <Dan> wrote in message
> news:D1E45EC6-011A-4829-B99C-CE13AD794EDC@microsoft.com...
> > Hi Ken,
> > Sorry about the confusion - I am using MS Outlook 2007. The issue about
> > the
> > folder and 50 messages, I need to send some files to friend of mine which
> > is
> > about 50 MB but provider doesn't let emails through that have attachments
> > that are more 500 KB, therefore I had split them. Now I have 100 files and
> > I
> > will have to create an email for each file. Like 1st email and attache 1st
> > file, and then create 2nd email and attach 2nd file and so one until I am
> > done attaching all 100 files (that is why I called it loop - do until
> > finish
> > all files in a folder). It is a bit tiresome and that is the reason I had
> > asked for help! Do you think there is anything available at Outlook
> > Programming-VBA community?
> > With best regards
> > Dan


>
 
K

Ken Slovak - [MVP - Outlook]

Re: signature & picture

You need to read any replies to you posts and not just keep posting the same

things.

This thread you latched onto has nothing at all to do with your question,

which was already answered in one of your original threads.

"Curt" <Curt> wrote in message

news:C311E887-A79D-4A89-9AA4-02C741AB7F2D@microsoft.com...
> Not familar with outlook VBA have used excel & word. Would like to build a
> macro that will insert a signature & a picture on one stroke. I use a two
> step method now only on forward or reply messages. If i create a new
> message
> it will not allow me to insert signature & picture. Useing 2000 & xp
> Any code I can work with will be appreciated.
> Thanks

> " - " wrote:
>
> > I don't think there's anything specific for something like that, if it
> > was
> > me and I didn't own a Web site I'd just use one of those public sites
> > where
> > you can post files for FTP downloads, or something like that. I'd also be
> > looking for a different ISP, that limitation is absurd.
>

>> You can use something like FileSystemObject to get at the folder and all
> > files in it. Then loop and iterate each file and add it as an attachment
> > to
> > a mail item. Something like this I suppose, which would require a VBA
> > project reference for the MS Scripting Runtime (scrrun.dll):
>

>> Dim FSO As Scripting.FileSystemObject
> > Dim tFile As Scripting.File
> > Dim oFolder As Scripting.Folder
> > Dim sPath As String
> > Dim sTemp As String
>

>> Set FSO = CreateObject("Scripting.FileSystemObject")
> > sPath = "C:\"
> > Set oFolder = FSO.GetFolder(sPath)
> > For Each tFile In oFolder.Files
> > sTemp = sPath & tFile.name
>

>> Set oMail = Application.CreateItem(olMailItem)
>

>> oMail.Subject = "More files"
>

>> Set oRecip = oMail.Recipients.Add("joe@test.com")
> > oRecip.Resolve
>

>> oMail.Attachments.Add(sTemp)
>

>> oMail.Send
> > Next
>

>
>> > >

> >

>

>
>
>
>
>
>> "Dan" <Dan> wrote in message
> > news:D1E45EC6-011A-4829-B99C-CE13AD794EDC@microsoft.com...
> > > Hi Ken,
> > > Sorry about the confusion - I am using MS Outlook 2007. The issue about
> > > the
> > > folder and 50 messages, I need to send some files to friend of mine
> > > which
> > > is
> > > about 50 MB but provider doesn't let emails through that have
> > > attachments
> > > that are more 500 KB, therefore I had split them. Now I have 100 files
> > > and
> > > I
> > > will have to create an email for each file. Like 1st email and attache
> > > 1st
> > > file, and then create 2nd email and attach 2nd file and so one until I
> > > am
> > > done attaching all 100 files (that is why I called it loop - do until
> > > finish
> > > all files in a folder). It is a bit tiresome and that is the reason I
> > > had
> > > asked for help! Do you think there is anything available at Outlook
> > > Programming-VBA community?
> >> > With best regards
> > > Dan

>

>>
 
Status
Not open for further replies.
Similar threads
Thread starter Title Forum Replies Date
S Macro for Loop through outlook unread emails Outlook VBA and Custom Forms 2
A VBA macro for 15 second loop in send and received just for 1 specific mailbox Outlook VBA and Custom Forms 1
A ItemAdd on Imap Folder get endless loop after saving item Using Outlook 5
makinmyway Trouble Installing BCM Outlook 2013; Endless Install Loop Happens Using Outlook 0
W Broken Folder Loop - Outlook 2007 (.oft files) Using Outlook 2
Forum Admin Endless loop when to the new Outlook Connector Using Outlook.com accounts in Outlook 0
S Business Contact Manager (BCM) causing Outlook crash loop BCM (Business Contact Manager) 3
K loop through distribution group (and potentially, embedded DGs) by Outlook VBA and Custom Forms 1
H For Each loop not getting all Email Items Outlook VBA and Custom Forms 3
S Loop mail items within a Custom Search Folder Outlook VBA and Custom Forms 1
M If loop not running Outlook VBA and Custom Forms 1
M Outlook VBA Form not finding FOR LOOP -- Error message Outlook VBA and Custom Forms 2
D Create new email from the received Email Body with attachment Outlook VBA and Custom Forms 10
T vba extract data from msg file as attachment file of mail message Outlook VBA and Custom Forms 1
K Outlook Office 365 VBA download attachment Outlook VBA and Custom Forms 2
P Sending email from outlook IMAP to GMAIL where embedded images are added as attachment Using Outlook 1
S save attachment with date & time mentioned inside the file Outlook VBA and Custom Forms 0
O VBA Outlook Message Attachment - Array Index Out of Bounds Outlook VBA and Custom Forms 0
A Edit attachment Save and Reply Outlook VBA and Custom Forms 0
D Move Email with Attachment to Folder Outlook VBA and Custom Forms 3
B Outlook 2010 Opening Mail Attachment Using Outlook 2
A Warning When Opening attachment Using Outlook 7
R Limiting length of saved attachment in VBA Outlook VBA and Custom Forms 2
F Script for zip file attachment Outlook VBA and Custom Forms 1
P Outlook 2013 Word Share doc as Email Attachment now brings up Eudora. Using Outlook 1
L Attachment saving and tracking - PLEASE help! Outlook VBA and Custom Forms 5
H Outlook 2003 find by "has attachment" Using Outlook 1
9 Outlook 2016 How to save an Outlook attachment to a specific folder then delete the email it came from? Using Outlook 1
J Add an Attachment Using an Array and Match first 17 Letters to Matching Template .oft to Send eMail Outlook VBA and Custom Forms 2
geofferyh Cannot get Macro to SAVE more than one message attachment??? Outlook VBA and Custom Forms 5
geofferyh How to change the Attachment File Name? Outlook VBA and Custom Forms 1
geofferyh Outlook 2010 How to Copy Outlook Attachment to a Specific Folder? Outlook VBA and Custom Forms 3
D Body text of email disappears when I scan an attachment from printer to email Using Outlook 1
J Help Please!!! Outlook 2016 - VBA Macro for replying with attachment in meeting invite Outlook VBA and Custom Forms 9
W Save Outlook attachment in network folder and rename to current date and time Outlook VBA and Custom Forms 18
D Autosave Attachment and Rename Outlook VBA and Custom Forms 1
N Macro for attachment saved and combine Outlook VBA and Custom Forms 1
Andrew Quirl Open attachment, manipulate without add-on program? Outlook VBA and Custom Forms 5
V VB script code to save a specific email attachment from a given email Outlook VBA and Custom Forms 14
Commodore Attachment icon when there is no attachment Using Outlook 3
V Saving attachment from outlook in My Documents Outlook VBA and Custom Forms 14
N automatic response with an attachment based on the subject line Outlook VBA and Custom Forms 1
J Auto Forward - Include Attachment and change Subject depending on original sender Outlook VBA and Custom Forms 3
M Search for attachment filename Using Outlook 0
E Open olNoteItem Attachment Outlook VBA and Custom Forms 6
Vijay Reply all by attachment name Using Outlook 10
Michael R Belleville Making an Attachment Name the Message Subject Using Outlook 2
N Paste content to Excel when .txt file (attachment) is opened Outlook VBA and Custom Forms 1
P Outlook Randomly Not attaching (attachment file) Using Outlook 0
S VBA to search a keyword in attachment and move to a folder Outlook VBA and Custom Forms 0

Similar threads

Top