EMail to multiple receipents

js982

New member
Local time
Today, 22:51
Joined
Dec 26, 2004
Messages
7
Hi all,
I'm sure this is any easy question for a lot of you...
I want to send out an E-Mail to multiple receipents.
This E-mail does currently only have one attach.
I have been looking for some code and came up with the following:


Private Sub Command44_Click()

Dim MailApp As Outlook.Application
Dim NewEmail As MailItem
Set MailApp = CreateObject("Outlook.Application")
Set NewEmail = MailApp.CreateItem(olMailItem)

Dim atts As Outlook.Attachments
Dim newAttachment As Outlook.Attachment

Dim rsEMail As DAO.Recordset
Dim strEMail As String
Set rsEMail = CurrentDb.OpenRecordset("Qry_Contacts / Doc type Subform")
Do While Not rsEMail.EOF
strEMail = strEMail & rsEMail.Fields("EMail") & ";"

rsEMail.MoveNext
Loop
strEMail = Left(strEMail, Len(strEMail) - 1)
With NewEmail

.To = (strEMail)
.Subject = ([Forms]![Frm_DocData]![Document Titel])
.Body = (Forms![Frm_DocData]![Document Summary])
Set atts = .Attachments
'Do until recordset.eof
Set newAttachment = atts.Add((Forms![Frm_DocData]![Document Link]), olByValue, 1)
'Loop
'.Send
.Display
End With
Set rsEMail = Nothing
Set NewEmail = Nothing
Set MailApp = Nothing

End Sub

In fact, this is a mix of 2 codes I found on this forum.
When I run this, I get a run-time error '3061'
Too few parameters.

Can you maybe point out what I am doing wrong or what I should do different?

Thanks!
 
Wrong query

OK,

Problems seems to be related to the query.
It did not return any values...
But when I run it seperatly, it gives me the data I need?!
 
I Changed the query name in:
Set rsEMail = CurrentDb.OpenRecordset("Qry_Contacts / Doc type Subform")

to the SQL query string

Set rsEMail = CurrentDb.OpenRecordset("SELECT [Tbl_Available Contacts].Name, [Tbl_Available Contacts].EMail, Tbl_Contacts.[ID Document Type] FROM [Tbl_Available Contacts] INNER JOIN Tbl_Contacts ON [Tbl_Available Contacts].[Contact ID] = Tbl_Contacts.[Available Contact ID] WHERE (((Tbl_Contacts.[ID Document Type])=" & [Forms]![Frm_DocData]![Document Type ID] & "));")

now it works.
 
If you want to send to multiple recipiants you can put the address list together as a string.

I've use it on an outlook appointment Item I basically set up a hidden combobox that concatenated the email field with ";" seperators, I then use this to get the .To value from

It is basically three nested queries:
QryOne
SELECT qry_Booking_Mail_New.CourseCode AS ID, qry_Booking_Mail_New.Email AS Field2, tbl_Courses.CourseName, tbl_Days.Minutes, tbl_Courses.Invitation, qry_Booking_Mail_New.Action
FROM tbl_Days INNER JOIN (qry_Booking_Mail_New RIGHT JOIN tbl_Courses ON qry_Booking_Mail_New.CourseCode = tbl_Courses.CourseCode) ON tbl_Days.Days = tbl_Courses.NoDays;


qrytwo
SELECT qryOne.ID, qryOne.CourseName, qryOne.Minutes, qryOne.Invitation, Conc("Field2","ID",[ID],"qryOne") AS Field2, qryOne.Action
FROM qryOne
GROUP BY qryOne.ID, qryOne.CourseName, qryOne.Minutes, qryOne.Invitation, qryOne.Action;

Final Query
SELECT qryTwo.ID, qryTwo.CourseName, qryTwo.Minutes, qryTwo.Invitation, Replace([Field2],",",";") AS Mail, qryTwo.Field2, [Mail] & ";" AS Expr1, qryTwo.Action
FROM qryTwo;


This final query is the one I took the value from...not a very eloquant way of doing it, but it worked
 

Users who are viewing this thread

Back
Top Bottom