L
Lisa
I posted the following email under Outlook VBA newsgroup
with no response, but noticed this newsgroup today which
better fits my question. I need to find a solution or
workaround ASAP. Any ideas would be appreciated. Thanks!!
I have an Access 2000 database creating attachments and
then mailing them out to users via Outlook (2000 SR-1). I
have everything working except the program needs to send
out 47 and it stops at 33 (for one month) and another
month stops at 30 instead of the total 41. The program
runs without any errors.
Is there any restrictions on using office automation to
send emails through Outlook? Is there any sort of session
time out? Is there some sort of security setting that I
should know about? Below is the code I am using to create
the file and email.
Private Sub cmdExport_Click()
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim olApp As New Outlook.Application
Dim olSpace As Outlook.NameSpace
Dim olMsg As Outlook.MailItem
Dim olAttach As Outlook.Attachment
Dim strSQL As String
Dim strFileName As String
Dim intExportCount As Integer
If Not IsNull(Me.cboMonth) Then
intExportCount = 0
strSQL = "SELECT BpnForm.BpnFormID,[OfficeID] &
[OfficeID4] AS FileName, [ID Requests].SubmitterEmail " & _
"FROM StatusTracking INNER JOIN ([ID
Requests] INNER JOIN BpnForm ON [ID Requests].RequestID =
BpnForm.RequestID) ON StatusTracking.RequestID =
BpnForm.RequestID " & _
"WHERE (((Format([ExpirationDate],'mmmm'))='"
& Me.cboMonth & "'));"
Set cnn = CurrentProject.Connection
rs.Open strSQL, cnn, adOpenStatic
Set olSpace = olApp.GetNamespace("MAPI")
olSpace.Logon FMPRG, "", False, False
With rs
If Not (.EOF And .BOF) Then
.MoveFirst
Do While Not .EOF
glngIDForExport = .Fields(0)
strFileName = "D:\" & .Fields(1) & ".xls"
DoCmd.OutputTo
acOutputQuery, "qry_Export", acFormatXLS, strFileName
formatfile (strFileName)
Set olMsg = olApp.CreateItem(olMailItem)
olMsg.To = .Fields(2)
olMsg.Subject = "Registration
Recertification"
olMsg.Body = "Last test..." & vbCrLf &
vbCrLf & strFileName
olMsg.Importance = olImportanceHigh
Set olAttach = olMsg.Attachments.Add
(strFileName)
olMsg.Display
Set olAttach = Nothing
Set olMsg = Nothing
intExportCount = intExportCount + 1
.MoveNext
Loop
Select Case intExportCount
Case 1
MsgBox "Export Complete" & vbCrLf &
intExportCount & " Record Processed"
Case Else
MsgBox "Export Complete" & vbCrLf &
intExportCount & " Records Processed"
End Select
Else
MsgBox "No Records to Export"
End If
.Close
End With
Set rs = Nothing
cnn.Close
Set cnn = Nothing
Set olApp = Nothing
Else
MsgBox "Select Month Before Exporting"
End If
End Sub
with no response, but noticed this newsgroup today which
better fits my question. I need to find a solution or
workaround ASAP. Any ideas would be appreciated. Thanks!!
I have an Access 2000 database creating attachments and
then mailing them out to users via Outlook (2000 SR-1). I
have everything working except the program needs to send
out 47 and it stops at 33 (for one month) and another
month stops at 30 instead of the total 41. The program
runs without any errors.
Is there any restrictions on using office automation to
send emails through Outlook? Is there any sort of session
time out? Is there some sort of security setting that I
should know about? Below is the code I am using to create
the file and email.
Private Sub cmdExport_Click()
Dim cnn As New ADODB.Connection
Dim rs As New ADODB.Recordset
Dim olApp As New Outlook.Application
Dim olSpace As Outlook.NameSpace
Dim olMsg As Outlook.MailItem
Dim olAttach As Outlook.Attachment
Dim strSQL As String
Dim strFileName As String
Dim intExportCount As Integer
If Not IsNull(Me.cboMonth) Then
intExportCount = 0
strSQL = "SELECT BpnForm.BpnFormID,[OfficeID] &
[OfficeID4] AS FileName, [ID Requests].SubmitterEmail " & _
"FROM StatusTracking INNER JOIN ([ID
Requests] INNER JOIN BpnForm ON [ID Requests].RequestID =
BpnForm.RequestID) ON StatusTracking.RequestID =
BpnForm.RequestID " & _
"WHERE (((Format([ExpirationDate],'mmmm'))='"
& Me.cboMonth & "'));"
Set cnn = CurrentProject.Connection
rs.Open strSQL, cnn, adOpenStatic
Set olSpace = olApp.GetNamespace("MAPI")
olSpace.Logon FMPRG, "", False, False
With rs
If Not (.EOF And .BOF) Then
.MoveFirst
Do While Not .EOF
glngIDForExport = .Fields(0)
strFileName = "D:\" & .Fields(1) & ".xls"
DoCmd.OutputTo
acOutputQuery, "qry_Export", acFormatXLS, strFileName
formatfile (strFileName)
Set olMsg = olApp.CreateItem(olMailItem)
olMsg.To = .Fields(2)
olMsg.Subject = "Registration
Recertification"
olMsg.Body = "Last test..." & vbCrLf &
vbCrLf & strFileName
olMsg.Importance = olImportanceHigh
Set olAttach = olMsg.Attachments.Add
(strFileName)
olMsg.Display
Set olAttach = Nothing
Set olMsg = Nothing
intExportCount = intExportCount + 1
.MoveNext
Loop
Select Case intExportCount
Case 1
MsgBox "Export Complete" & vbCrLf &
intExportCount & " Record Processed"
Case Else
MsgBox "Export Complete" & vbCrLf &
intExportCount & " Records Processed"
End Select
Else
MsgBox "No Records to Export"
End If
.Close
End With
Set rs = Nothing
cnn.Close
Set cnn = Nothing
Set olApp = Nothing
Else
MsgBox "Select Month Before Exporting"
End If
End Sub