Hello All,
I have the below code in a module to call outlook. The problem i am having is the .To part. The outlook dialogue does pop up but all of the emails located in the Query1 do not show up in the To box in outlook. The .CC shows all the emails for the manager but .to box only shows 1 email
Set oOutlook = GetObject(, "Outlook.Application")
If oOutlook Is Nothing Then
Set oOutlook = New Outlook.Application
End If
Set oEmailItem = oOutlook.CreateItem(olMailItem)
With oEmailItem
Set rs = CurrentDb.OpenRecordset("SELECT * FROM Query1")
If rs.RecordCount > 0 Then
rs.MoveFirst
Do Until rs.EOF
If IsNull(rs!Email) Then
rs.MoveNext
Else
AssociateEmail = customerEmail & rs!Email & ";"
ManagerEmail = ManagerEmail & rs!ManagerEmail & ";"
.To = AssociateEmail
.CC = ManagerEmail
rs.MoveNext
End If
Loop
End If
Set rs = Nothing
.Importance = olImportanceHigh
.Subject = "Action Needed: OPUS - User Access Review - by Date"
'.Attachments.Add FilePath'
I have the below code in a module to call outlook. The problem i am having is the .To part. The outlook dialogue does pop up but all of the emails located in the Query1 do not show up in the To box in outlook. The .CC shows all the emails for the manager but .to box only shows 1 email
Set oOutlook = GetObject(, "Outlook.Application")
If oOutlook Is Nothing Then
Set oOutlook = New Outlook.Application
End If
Set oEmailItem = oOutlook.CreateItem(olMailItem)
With oEmailItem
Set rs = CurrentDb.OpenRecordset("SELECT * FROM Query1")
If rs.RecordCount > 0 Then
rs.MoveFirst
Do Until rs.EOF
If IsNull(rs!Email) Then
rs.MoveNext
Else
AssociateEmail = customerEmail & rs!Email & ";"
ManagerEmail = ManagerEmail & rs!ManagerEmail & ";"
.To = AssociateEmail
.CC = ManagerEmail
rs.MoveNext
End If
Loop
End If
Set rs = Nothing
.Importance = olImportanceHigh
.Subject = "Action Needed: OPUS - User Access Review - by Date"
'.Attachments.Add FilePath'