|
-
Aug 25th, 2009, 12:29 PM
#1
Thread Starter
Member
Sending Email to Multiple Addresses Located in a Database
Background Info - Hi everyone. I am trying to send an email to multiple addresses on a button click. I store my addresses in a SQL Server database view vrptJudicalCalendarAtt and have a private sub that would take the addresses and put them into a string that has " ; ". Then use the SendObject method to send my email with attachment and get the addresses from the private sub.
Here is my code for the private sub:
Code:
Private Function EmailList() As String
'-- Return all of the email addresses in the EmailAddress table
'-- as one string separated with a semicolon ";"
On Error GoTo Err_EmailList
Dim DB As Database
Dim rs As DAO.Recordset
Set DB = CurrentDb
Set rs = DB.OpenRecordset("Select Email From vrptJudicalCalendarAtt Where CaseNumber = '" & fld1 & "'", dbOpenForwardOnly)
With rs
Do While Not rs.EOF
EmailList = EmailList & ![Email] & ";"
rs.MoveNext
Loop
End With
'-- Strip off the last ";"
EmailList = Left(EmailList, Len(EmailList) - 1)
Exit_EmailList:
If Not rs Is Nothing Then
rs.Close
Set rs = Nothing
End If
Exit Function
Err_EmailList:
MsgBox "Error No: " & err.Number & vbCr & _
"Description: " & err.Description
Resume Exit_EmailList
End Function
Here is the code for the btn Click:
Private Sub btnEmailCase_Click()
On Error GoTo MailError
DoCmd.SendObject acSendReport, "rptJudicialcalendarValidation", acFormatRTF, EmailList(), , , "Sandusky County Hearing Notice", "Hearing Notice for " & Caption1 & " Case Number: " & CaseNumber & " at " & Right([BeginTime], 11) & " on " & BeginDate & ""
MailError:
MsgBox "Email Your Was Not Sent"
End Sub
Last edited by RobDog888; Aug 26th, 2009 at 03:51 AM.
Reason: Added [code] tags
-
Aug 25th, 2009, 12:36 PM
#2
Thread Starter
Member
Re: Sending Email to Multiple Addresses Located in a Database
The problem is that I cannot get the email list to show up correctly can i get a little help?
Thanks.
-
Aug 26th, 2009, 03:52 AM
#3
Re: Sending Email to Multiple Addresses Located in a Database
Welcome to the Forums.
Can you explain more of what you mean by "show up correctly"? Whats the correct way it should be showing vs how its actually showing.
VB/Office Guru™ (AKA: Gangsta Yoda™ ®)
I dont answer coding questions via PM. Please post a thread in the appropriate forum. 
Microsoft MVP 2006-2011
Office Development FAQ (C#, VB.NET, VB 6, VBA)
Senior Jedi Software Engineer MCP (VB 6 & .NET), BSEE, CET
If a post has helped you then Please Rate it! 
• Reps & Rating Posts • VS.NET on Vista • Multiple .NET Framework Versions • Office Primary Interop Assemblies • VB/Office Guru™ Word SpellChecker™.NET • VB/Office Guru™ Word SpellChecker™ VB6 • VB.NET Attributes Ex. • Outlook Global Address List • API Viewer utility • .NET API Viewer Utility •
System: Intel i7 6850K, Geforce GTX1060, Samsung M.2 1 TB & SATA 500 GB, 32 GBs DDR4 3300 Quad Channel RAM, 2 Viewsonic 24" LCDs, Windows 10, Office 2016, VS 2019, VB6 SP6 
-
Sep 8th, 2009, 10:54 AM
#4
Thread Starter
Member
Re: Sending Email to Multiple Addresses Located in a Database
I got it up and running thanks.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|