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!
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!