Hi
I have been using this codes for some time to send to Recipients using the query
The list of emails getting added to the "TO" list
Some of the people in the list have said they now do not want other people to see their email, how can I modify this code so that the list created gets added to "BCC" not "TO"
Thanks for your help
Private Sub CommandSendEmails_Click()
DoCmd.SetWarnings False
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT TblEmailList.* FROM TblEmailList"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
Do Until rs.RecordCount = 0
With rs
.MoveFirst
.Delete
.MoveNext
End With
Loop
DoCmd.OpenQuery "QryMyEmailAddresses"
Dim MailList As DAO.Recordset
Dim MyOutlook As Outlook.Application
Dim myMail As Outlook.MailItem
Dim Subjectline As String
Dim BodyFile As String
Dim MyBodyText As String
Dim rsemail As DAO.Recordset
Dim ns As Outlook.NameSpace
Dim Folder As Outlook.MAPIFolder
Dim mysql As String
Subjectline$ = "Information about Tai Chi"
DoCmd.SetWarnings False
Set MyOutlook = New Outlook.Application
Set MyOutlook = CreateObject("Outlook.Application")
Set ns = MyOutlook.GetNamespace("MAPI")
Set Folder = ns.GetDefaultFolder(olFolderInbox)
MyOutlook.Explorers.Add Folder
Set db = CurrentDb()
mysql = "SELECT DISTINCT TblEmailList.email FROM TblEmailList;"
Set rsemail = db.OpenRecordset(mysql)
Set myMail = MyOutlook.CreateItem(olMailItem)
Do Until rsemail.EOF
'this allows you to send one email to multiple recipients
myMail.Recipients.Add rsemail(0)
'And on to the next one...
rsemail.MoveNext
Loop
'This gives it a subject
myMail.BCC = strSQL
myMail.Subject = Subjectline$
myMail.SendUsingAccount = MyOutlook.Session.Accounts.Item(1)
myMail.Body = "Hi Everyone, " & Chr(13) & Chr(13) & "Enter your email text Here" & Chr(13) & Chr(13) & "Best Wishes" & Chr(13) & Chr(13) & "Dee"
myMail.Display
Set myMail = Nothing
Set MyOutlook = Nothing
DoCmd.SetWarnings True
rsemail.Close
db.Close
Set db = Nothing
Exit Sub
End Sub
I have been using this codes for some time to send to Recipients using the query
The list of emails getting added to the "TO" list
Some of the people in the list have said they now do not want other people to see their email, how can I modify this code so that the list created gets added to "BCC" not "TO"
Thanks for your help
Private Sub CommandSendEmails_Click()
DoCmd.SetWarnings False
Dim db As DAO.Database
Dim rs As DAO.Recordset
Dim strSQL As String
strSQL = "SELECT TblEmailList.* FROM TblEmailList"
Set db = CurrentDb()
Set rs = db.OpenRecordset(strSQL, dbOpenDynaset)
Do Until rs.RecordCount = 0
With rs
.MoveFirst
.Delete
.MoveNext
End With
Loop
DoCmd.OpenQuery "QryMyEmailAddresses"
Dim MailList As DAO.Recordset
Dim MyOutlook As Outlook.Application
Dim myMail As Outlook.MailItem
Dim Subjectline As String
Dim BodyFile As String
Dim MyBodyText As String
Dim rsemail As DAO.Recordset
Dim ns As Outlook.NameSpace
Dim Folder As Outlook.MAPIFolder
Dim mysql As String
Subjectline$ = "Information about Tai Chi"
DoCmd.SetWarnings False
Set MyOutlook = New Outlook.Application
Set MyOutlook = CreateObject("Outlook.Application")
Set ns = MyOutlook.GetNamespace("MAPI")
Set Folder = ns.GetDefaultFolder(olFolderInbox)
MyOutlook.Explorers.Add Folder
Set db = CurrentDb()
mysql = "SELECT DISTINCT TblEmailList.email FROM TblEmailList;"
Set rsemail = db.OpenRecordset(mysql)
Set myMail = MyOutlook.CreateItem(olMailItem)
Do Until rsemail.EOF
'this allows you to send one email to multiple recipients
myMail.Recipients.Add rsemail(0)
'And on to the next one...
rsemail.MoveNext
Loop
'This gives it a subject
myMail.BCC = strSQL
myMail.Subject = Subjectline$
myMail.SendUsingAccount = MyOutlook.Session.Accounts.Item(1)
myMail.Body = "Hi Everyone, " & Chr(13) & Chr(13) & "Enter your email text Here" & Chr(13) & Chr(13) & "Best Wishes" & Chr(13) & Chr(13) & "Dee"
myMail.Display
Set myMail = Nothing
Set MyOutlook = Nothing
DoCmd.SetWarnings True
rsemail.Close
db.Close
Set db = Nothing
Exit Sub
End Sub