PDA

View Full Version : Sending emails to multiple recipients



Makat
07-07-2006, 07:34 AM
I have code to send an attachment each day to multiple recipients. The code sends the attachment separately to each person but since we just upgraded to 2003, it now brings up a message each time it trys to send the email:
"A program is trying to automatically send e-mail on your behalf. Do you want to allow this? If this is unexpected, it may be a virus and you should choose No".
You have to select Yes each time for the email to go through. It gets time consuming because there are about 30 recipients receiving the email.
If I could send just one email with the attachment to all recipients at once would help. Or if anyone knows of a way to get rid of that prompt would help also. Below is the code currently being used. Any advice is greatly appreciated. I am a novice at VBA.

Sub Send_All_Email()
'
' Send_Email Macro
On Error GoTo Out:
MyCheck = MsgBox("Have you entered TODAYS DATE - Emails may take 30 secs. to send", vbYesNo)
If MyCheck = vbNo Then
Exit Sub
Else
Range("h50").Select
Range("h5").Select
GoTo Start
End If
Start:
Call Password
ActiveWorkbook.SendMail "Person1.org (Phil.Beauchamp@baycare.org)", "Today's Report", Null
ActiveWorkbook.SendMail "Person2.org (joan.clow@baycare.org)", "Today's Report", Null
ActiveWorkbook.SendMail "Person3.org (brenda.balicki@baycare.org)", "Today's Report", Null
ActiveWorkbook.SendMail "Person4.org (pati.nolan@baycare.org)", "Today's Report", Null
ActiveWorkbook.SendMail "Person5.org (barbara.moss@baycare.org)", "Today's Report", Null
'Application.Dialogs(xlDialogSendMail).Show
GoTo Good:
Out:
MsgBox ("ERROR: Emails were NOT sent - Try Again or call IS at 123-4567")
MsgBox Err.Description, vbCritical
Range("h50").Select
Range("D5").Select
Exit Sub
Good:
MsgBox ("SUCCESS: All emails were sent")
MsgBox ("Verify emails were sent - check your SENT items before erasing data")
'MyCheck = MsgBox("Are You Ready to Erase ALL DATA", vbYesNo)
' If MyCheck = vbNo Then
' Exit Sub
' Else
' Call Erase_All_Data
'End If
Range("h50").Select
Range("D5").Select
Exit Sub
End Sub

lucas
07-07-2006, 07:47 AM
Thread in the outlook forum addresses this issue:
http://vbaexpress.com/forum/showthread.php?t=7847