I am exporting files to a number of clients, by looping thru
a recordset, I have found that I have to set the object in the loop otherwise it appears that the object is sent and only the first record will be sent. This doesn't seem like the proper way to code this.
Any suggestions on the proper way to code this.
Also does anyone know how to turn off the warning dialog stating that outlook is trying to send a message do you want to allow this, generated when this code is ran.
Any help will be appreciated.
aqua
Public olkApp As Outlook.Application
Public olkNameSpace As Outlook.NameSpace
Public Function email()
Dim rsEmailInfo As New ADODB.Recordset
Dim objMailItem As Outlook.MailItem
Set olkApp = New Outlook.Application
Set olkNameSpace = olkApp.GetNamespace("MAPI"
' Set objMailItem = olkApp.CreateItem(olMailItem)
Set rsEmailInfo = New ADODB.Recordset
rsEmailInfpen "Select * from email_Info ", _
CurrentProject.Connection, adOpenForwardOnly
rsEmailInfo.MoveFirst
Do While Not rsEmailInfo.EOF
Set objMailItem = olkApp.CreateItem(olMailItem)
With objMailItem
.To = rsEmailInfo!To
.CC = rsEmailInfo!CC
.Subject = rsEmailInfo!Subject
.Body = rsEmailInfo!Body
.Attachments.Add "C:\Practice.txt"
.Send
End With
rsEmailInfo.MoveNext
Loop
rsEmailInfo.Close
Set objMailItem = Nothing
Set olkNameSpace = Nothing
Set olkApp = Nothing
End Function
a recordset, I have found that I have to set the object in the loop otherwise it appears that the object is sent and only the first record will be sent. This doesn't seem like the proper way to code this.
Any suggestions on the proper way to code this.
Also does anyone know how to turn off the warning dialog stating that outlook is trying to send a message do you want to allow this, generated when this code is ran.
Any help will be appreciated.
aqua
Public olkApp As Outlook.Application
Public olkNameSpace As Outlook.NameSpace
Public Function email()
Dim rsEmailInfo As New ADODB.Recordset
Dim objMailItem As Outlook.MailItem
Set olkApp = New Outlook.Application
Set olkNameSpace = olkApp.GetNamespace("MAPI"
' Set objMailItem = olkApp.CreateItem(olMailItem)
Set rsEmailInfo = New ADODB.Recordset
rsEmailInfpen "Select * from email_Info ", _
CurrentProject.Connection, adOpenForwardOnly
rsEmailInfo.MoveFirst
Do While Not rsEmailInfo.EOF
Set objMailItem = olkApp.CreateItem(olMailItem)
With objMailItem
.To = rsEmailInfo!To
.CC = rsEmailInfo!CC
.Subject = rsEmailInfo!Subject
.Body = rsEmailInfo!Body
.Attachments.Add "C:\Practice.txt"
.Send
End With
rsEmailInfo.MoveNext
Loop
rsEmailInfo.Close
Set objMailItem = Nothing
Set olkNameSpace = Nothing
Set olkApp = Nothing
End Function