Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Email files using macro

I would like to email multiple files to multiple users using a macro.
I have created a macro that can send one file to multiple users using
a default mesaage, but am having difficulty sending more than one file
to more than one user. In addition, part of the the file name changes
each (the date element, the prefix / ext stay the same. Ideally, I
would like to incorporate a subject and a message for the email
besides attaching the file/s.
Here is the current macro which includes a progress bar and a subject
but no message:

Sub ProgressBar3(Msg1 As String, PctDone1 As Single)
With ProgressDlg3
.lblMessage.Caption = Msg1
.lblDone.Width = PctDone1 * (.lblRemain.Width - 2)
.lblPct.Caption = Format(PctDone1, "0%")
'.lblMessage2.Caption = Msg2
'.lblDone2.Width = PctDone2 * (.lblRemain2.Width - 2)
'.lblPct2.Caption = Format(PctDone2, "0%")
End With
'The DoEvents statement is responsible for the form updating
DoEvents
End Sub
Sub CommandButton1_Click()

Dim email(20) As String 'initialize the array to 20 rather than
bothering to code a redim later
Dim x As Integer
Dim p As Integer, totP As Integer, totE As Integer
Application.DisplayAlerts = True ' Turns ON
display alerts
Application.ScreenUpdating = True ' Turns ON
screen updating
Application.StatusBar = False
Workbooks.Open Filename:=Cells(1, 3) 'set the file you want to send
here.

totE = 1
'load address array from spreadsheet
While Cells(totE, 1) < ""
email(totE) = Cells(totE, 1)
'MsgBox "loaded " & totE & " as " & Cells(totE, 1)
totE = totE + 1
Wend

Load ProgressDlg3
ProgressDlg3.Show vbModeless

e = 1
totP = 14 ' number of pictures in animation
p = 0
On Error Resume Next ' ignore error if pictures are not found
ProgressDlg3.Image1.Picture = LoadPicture(ThisWorkbook.Path &
"\mail" & p & ".gif")
On Error GoTo 0
ProgressDlg3.Caption = "Sending e-mail"
For e = 1 To totE - 1
p = p + 1
If p totP Then p = 1
On Error Resume Next ' ignore error if pictures are not
found
ProgressDlg3.Image1.Picture =
LoadPicture(ThisWorkbook.Path & "\mail" & p & ".gif")
On Error GoTo 0
If e Mod 1 = 0 Then
ProgressBar3 email(p), e / totE
End If
ActiveWorkbook.SendMail Recipients:=email(e),
Subject:="Data File"
Next e
Unload ProgressDlg3
MsgBox e - 1 & " emails sent", vbInformation

Workbooks("data.xls").Close SaveChanges:=True ' Saves & Closes
File.
Windows("datafile.xls").Activate ' Switch Window &
Return to
Sheets("Macro Control").Select ' Macro Contol Tab

End Sub

__________________________________________________ __________

Any help would be greatly appreciated.

Thanks In advance..

David
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Using Macro how to create email link for the email addresses in aRange or Selection Satish[_2_] Excel Worksheet Functions 8 December 28th 09 03:30 PM
Macro to split excel file into seperate files and then email LITTLE PETE Excel Discussion (Misc queries) 1 October 6th 08 01:37 PM
Email files [email protected] Excel Worksheet Functions 0 May 8th 08 01:36 PM
How do I create an email macro to auto fill the email? Justin[_4_] Excel Discussion (Misc queries) 0 November 14th 07 10:49 PM
I can not email excel files newbe New Users to Excel 3 March 10th 05 04:09 PM


All times are GMT +1. The time now is 11:20 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"