A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Variable attachment and recipient vb



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old January 20th 06, 02:43 PM posted to microsoft.public.outlook.program_vba
Xluser@work
external usenet poster
 
Posts: 4
Default Variable attachment and recipient vb

i am trying to automate the sending of different attachments to a list of
recipients. So far I have the following code that will send all of the
attachments in a folder to a specified recipient:

Sub Automate()
Dim Count As Integer
Dim DirectoryFiles()
ChDir "C:\Location of files"
ffile = Dir("*.*")
Do While ffile ""
If ffile "" Then
ReDim Preserve DirectoryFiles(Count)
DirectoryFiles(Count) = ffile
Count = Count + 1
End If
ffile = Dir()
Loop
Dim objoutlook As Object
Dim objoutlookmsg As Object
Set objoutlook = CreateObject("Outlook.application")
Set objoutlookmsg = objoutlook.CreateItem(0)
With objoutlookmsg
.To = "
.Subject = "Test"
.Body = "Please find attached monthly reports"
'** Add all stored files**
For i = 0 To UBound(DirectoryFiles())
.Attachments.Add DirectoryFiles(i)
Next
.Send
End With
Set objoutlook = Nothing
Set objoutlookmsg = Nothing
End Sub

The issues I have now is how to alter the above to send each recipient their
correct files. For example I want cost centre manager A to receive all the
files in the folder C:\CostA while I want manager B to receive the files in
the folder C:\CostB.

Clearly this will also require different email addresses for each send also.

Any help with this would be very gratefully received.
Ads
  #2  
Old January 21st 06, 10:05 AM posted to microsoft.public.outlook.program_vba
Michael Bauer
external usenet poster
 
Posts: 435
Default Variable attachment and recipient vb

Am Fri, 20 Jan 2006 05:43:02 -0800 schrieb Xluser@work:

Simply loop thorugh your recipients first, read their names, addresses or
whatever and build the path from that information. Within that loop start
the loop through the directory and get all the files with Dir().

--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook



i am trying to automate the sending of different attachments to a list of
recipients. So far I have the following code that will send all of the
attachments in a folder to a specified recipient:

Sub Automate()
Dim Count As Integer
Dim DirectoryFiles()
ChDir "C:\Location of files"
ffile = Dir("*.*")
Do While ffile ""
If ffile "" Then
ReDim Preserve DirectoryFiles(Count)
DirectoryFiles(Count) = ffile
Count = Count + 1
End If
ffile = Dir()
Loop
Dim objoutlook As Object
Dim objoutlookmsg As Object
Set objoutlook = CreateObject("Outlook.application")
Set objoutlookmsg = objoutlook.CreateItem(0)
With objoutlookmsg
.To = "
.Subject = "Test"
.Body = "Please find attached monthly reports"
'** Add all stored files**
For i = 0 To UBound(DirectoryFiles())
.Attachments.Add DirectoryFiles(i)
Next
.Send
End With
Set objoutlook = Nothing
Set objoutlookmsg = Nothing
End Sub

The issues I have now is how to alter the above to send each recipient

their
correct files. For example I want cost centre manager A to receive all the
files in the folder C:\CostA while I want manager B to receive the files

in
the folder C:\CostB.

Clearly this will also require different email addresses for each send

also.

Any help with this would be very gratefully received.

 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Send To | Mail Recipient Geoff Outlook Express 3 March 1st 06 11:40 PM
Outlook Application variable problem Ram Add-ins for Outlook 0 February 12th 06 03:25 PM
Problem with sendto mail recipient [email protected] Outlook Express 5 January 30th 06 07:04 AM
string variable that contains formatting Martin Outlook and VBA 4 January 19th 06 10:49 AM
using Send To, Mail Recipient Martin Outlook and VBA 3 January 16th 06 05:30 PM


All times are GMT +1. The time now is 08:38 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.