Hi,
I have created a Sendmail function on one of my pages but am having some problems getting it to work the way I want. At the moment it opens a seperate e-mail for every e-mail address in my query. How can I change the script below so that it opens just one e-mail with all the e-mail addresses listed under BCC rather than several e-mails, each with just one recipient?
Any help would be massively appreciated!
Thanks!
I have created a Sendmail function on one of my pages but am having some problems getting it to work the way I want. At the moment it opens a seperate e-mail for every e-mail address in my query. How can I change the script below so that it opens just one e-mail with all the e-mail addresses listed under BCC rather than several e-mails, each with just one recipient?
Code:
Public Sub SendMail()
Dim dbs As DAO.Database
Dim rst As DAO.Recordset
Dim rst2 As DAO.Recordset
Dim strSubject As String
Dim strEmailAddress As String
Dim strEmailAddress2 As String
Dim strEMailMsg As String
Dim ingCounter As Integer
Dim intCount As Integer
Set fso = CreateObject("Scripting.FileSystemObject")
Set theFile = fso.CreateTextFile("C:\Email.htm", vbTrue)
theFile.WriteLine "<HTML>"
theFile.WriteLine "<BODY style='font-family:Century Gothic;'>"
theFile.WriteLine "<p></p>"
theFile.WriteLine [Message]
theFile.WriteLine "<br />"
' theFile.WriteLine fso.OpenTextFile("K:\Admin & office\logo & letterhead\email-signature.html").ReadAll
theFile.WriteLine "</BODY>"
theFile.WriteLine "</HTML>"
theFile.Close
Set f = fso.OpenTextFile("C:\Email.htm", 1)
MyHTML = f.ReadAll
f.Close
strSubject = [Subject]
Set dbs = CurrentDb
Set rst = dbs.OpenRecordset("qryEmailOut")
rst.MoveFirst
Do Until rst.EOF
strEmailAddress = rst![email address]
strEMailMsg = MyHTML
DoCmd.SendObject acSendNoObject, stDocName, acFormatRTF, , _
, strEmailAddress, strSubject, strEMailMsg, , True
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
dbs.Close
Set dbs = Nothing
DoCmd.SetWarnings False
DoCmd.SetWarnings True
End Sub
Any help would be massively appreciated!
Thanks!