Sending Attachments to recipients

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to macro sending attachments to multiple recipients. I have
14 reports that go to 14 distribution lists. Each report going to its own
distribuing list. I do this once permonth and the distribution list is the
same but the report names are different. Example

xyz distribution list gets "c:\report\xyz\xyz report jan.xls"
abc distribuion list gets "c:\report\abc\abc report jan.xls"

etc.

The report being sent is always the most recent in the respective directory.

Any suggestions are greatly appreciated
 
Hi Michael,

the easiest way for getting the file informations would be the using of
the FileSystemObject (Microsoft Scripting Runtime, scrrun.dll).

Once, you have the newest file, you can call CreateItem for a new
MailItem, and it´s Attachments.Add for adding the file.
 
Thanks for your answer Michael, I am trying out somethings based on your
response.

How would I macro it to just populate a new mail with the list and then
prompt me for a file to attach. That would be quicker that what I do now.

I was thinking that since my directory is the same name as my distribution
list I could some how piece together a way to choose the file from that?

Eventhoug I am learning some basics I am still a total novice when it comes
to writing these pieces.

Thanks

Michael
 
Hi Michael,

sorry, but I don´t understand you.

What kind of list do you mean? And when do you want to be prompted?

Did you take a look at the Scripting Runtime, as I suggested?
 
I began looking at the Scripting Runtime and will continue to investigate. I
was just trying to maybe find another way to choose the file that will be
attached.

When writing these script pieces I usually try and mimic the manual process.
Manually I would open a new message select my distribution list, type in my
subject, attach my file.

I would want my code to do those tasks. Right now I am at ground zero on my
code. My idea was this:

Create an array that contains my Distribution list
Start a loop process
Open New message
Select first item in array
create the subject
based on the item(recipient) select the file
attach the file
send
next
when there are no more items left
exit

That is what I had in mind. I am thinking the Scripting Runtime would be
used where the file is being selected? or will it be outside of this?
 
Michael,

Thanks for your response. Sometimes I don't do such a great job at
communicating ideas that I don't fully understand.

The list I was refering to was the distribution list.

This is what I had in mind:

creat an array of values for my D/L

(xyz, abc, 123) etc.

start a loop

if finished with array
end
else
open new message
sendto: (next array value)
enter subject text : "monthly report"
add attachment (file location based on array value) file based on most recent
send
loop

I mainly stuck on the choosing the file and I am thinking your suggestion
of scripting runtime would go in the middle of the loop where I am trying to
select the file.

As far as my mentioning prompting I was thinking about for only file
selction that it would just prompt me for a file and once I selected the file
the code would continue to the next value in the array.

I may be way off in my design.
 
Hi Michael,

- If you want to attach the file automatically and the file name and/or
path can be different then you need some code that can find the file for
you.

- If the files would be the same, then you could store it´s names and
paths in a string (that would be "hard-coded").

- If the path is always the same and just the file name differs but can
be read from the DL name e.g., then you could join the hard-coded path
and the DL name.

You had written, that you need to select the newest file from a given
folder. For that you would need some code, that can do this selection
for you. And in this scenario the Scripting Runtime is IMHO neither the
only nor the best, but the easiest way.

As for almost every problem there is an alternative, of course: In your
loop you could display the created MailItem, call the proper
CommandBar.Execute method (FaceID=1079) and select the file manually :-)
 
Thanks.

I am going to get some code in place. Thanks to your suggestions I feel I
am much farther along than I was.
 
I have an Excel spreadsheet with some vba code to do this. It worked until
our IT dept "upgraded" to a new version of Outlook. If someone can help me
debug, I'll gladly share it.
 
Back
Top