Hello!
I was previously able to use this code successfully to send a single or group email to chosen contacts:
Code:
Dim db As DAO.Database
Dim MailList As DAO.Recordset
Dim MyOutlook As Outlook.Application
Dim MyMail As Outlook.MailItem
Dim Subjectline As String
Dim BodyFile As String
Dim MyBody As String
Dim MyBodyText As String
On Error GoTo ErrorHandler
Dim strBCC As String
Set lst = Me![lstSelectContacts]
'Check that at least one contact has been selected
If lst.ItemsSelected.Count = 0 Then
MsgBox "Please select at least one contact"
lst.SetFocus
GoTo ErrorHandlerExit
End If
'Test for required fields
'strTo = Me![txtTo].Value
'If strTo = "" Then
' strTo = "someone@microsoft.com"
'End If
strSubject = Me![txtSubject].Value
If strSubject = "" Then
MsgBox "Please enter a subject"
Me![txtSubject].SetFocus
GoTo ErrorHandlerExit
End If
strBody = Me![txtBody].Value
If strBody = "" Then
MsgBox "Please enter a message body"
Me![txtBody].SetFocus
GoTo ErrorHandlerExit
End If
'Add contacts to variable for BCC field
For Each varItem In lst.ItemsSelected
'Check for email address
strEMailRecipient = Nz(lst.Column(1, varItem))
' Debug.Print "EMail address: " & strEMailRecipient
If strEMailRecipient <> "" Then
strBCC = strBCC & strEMailRecipient & ";"
End If
Next varItem
strBCC = Left(strBCC, Len(strBCC) - 1)
'Create new mail message and send to contacts
Set msg = appOutlook.CreateItem(olMailItem)
With msg
'.To = strTo
.Subject = strSubject
.Body = strBody
.BCC = strBCC
.Display
.Send
End With
MsgBox "Emails have been sent"
ErrorHandlerExit:
Exit Sub
ErrorHandler:
MsgBox "Error No: " & Err.Number & "; Description: " & Err.Description
Resume ErrorHandlerExit
But since upgrading to 2016 (Office 365), I get the error: "You don't have permission to create an entry in this folder. Right-click the folder, and then click Properties to check your permissions for the folder. etc." I have made sure the folder Office16 allows full control for all users (I'm the only user on my computer). Not sure where else to look. Suggestions greatly appreciated as always.