OK, So i have used the help of a few people on here to get the code below running properly. It has run great for a little while. Now when I send emails using code below, I sometimes get a Reserved Error and it does not send any more emails. Please help and let me know what I need to do to fix this.
[Code=vb]
Private Sub Form_Load()
On Error GoTo Err_Form_Load
Dim rst As DAO.Recordset
Dim bkMark As String
Dim stDocName As String
Dim strSendTo As String
Dim strSubject As String
Dim strMessageText As String
Set rst = Me.RecordsetClo ne
If rst.EOF Then
MsgBox "There is no Email Address for Supplier's in this Branch Report File", vbExclamation, "No e-mail addresses"
rst.Close
Set rst = Nothing
DoCmd.Close acForm, "Email", acSaveYes
Exit Sub
End If
Do While rst.EOF = False
bkMark = rst.Bookmark
Me.Bookmark = bkMark
stDocName = "Request for Updated PO Info EMAIL"
strSendTo = rst![EmailAddress]
strSubject = "Wesco Distribution Status Update Report"
strMessageText = "To: " & rst![SupplierName] & vbCrLf _
& "" & vbCrLf _
& "C/O: " & rst![ContactName] & vbCrLf _
& "" & vbCrLf _
& "Attached is a status update report for specific PO line items." & vbCrLf _
& "" & vbCrLf _
& "Please review the attached report and reply back to this email with the requested information." & vbCrLf _
& "" & vbCrLf _
& "If you have any questions or concerns, contact information is located on the attached report." & vbCrLf _
& "" & vbCrLf _
& "Thank you," & vbCrLf _
& "" & vbCrLf _
& "Wesco Distribution Purchasing Department "
DoCmd.SendObjec t acSendReport, stDocName, acFormatRTF, strSendTo, , , strSubject, strMessageText, 0
rst.MoveNext
Loop
MsgBox "All emails have been sent to Suppliers", 0, "Email Complete"
rst.Close
Set rst = Nothing
DoCmd.Close acForm, "Email", acSaveYes
Exit_Form_Click :
Exit Sub
Err_Form_Load:
MsgBox Err.Description
Resume Exit_Form_Click
End Sub
[/Code]
Thank you In Advance.
Nick
[Code=vb]
Private Sub Form_Load()
On Error GoTo Err_Form_Load
Dim rst As DAO.Recordset
Dim bkMark As String
Dim stDocName As String
Dim strSendTo As String
Dim strSubject As String
Dim strMessageText As String
Set rst = Me.RecordsetClo ne
If rst.EOF Then
MsgBox "There is no Email Address for Supplier's in this Branch Report File", vbExclamation, "No e-mail addresses"
rst.Close
Set rst = Nothing
DoCmd.Close acForm, "Email", acSaveYes
Exit Sub
End If
Do While rst.EOF = False
bkMark = rst.Bookmark
Me.Bookmark = bkMark
stDocName = "Request for Updated PO Info EMAIL"
strSendTo = rst![EmailAddress]
strSubject = "Wesco Distribution Status Update Report"
strMessageText = "To: " & rst![SupplierName] & vbCrLf _
& "" & vbCrLf _
& "C/O: " & rst![ContactName] & vbCrLf _
& "" & vbCrLf _
& "Attached is a status update report for specific PO line items." & vbCrLf _
& "" & vbCrLf _
& "Please review the attached report and reply back to this email with the requested information." & vbCrLf _
& "" & vbCrLf _
& "If you have any questions or concerns, contact information is located on the attached report." & vbCrLf _
& "" & vbCrLf _
& "Thank you," & vbCrLf _
& "" & vbCrLf _
& "Wesco Distribution Purchasing Department "
DoCmd.SendObjec t acSendReport, stDocName, acFormatRTF, strSendTo, , , strSubject, strMessageText, 0
rst.MoveNext
Loop
MsgBox "All emails have been sent to Suppliers", 0, "Email Complete"
rst.Close
Set rst = Nothing
DoCmd.Close acForm, "Email", acSaveYes
Exit_Form_Click :
Exit Sub
Err_Form_Load:
MsgBox Err.Description
Resume Exit_Form_Click
End Sub
[/Code]
Thank you In Advance.
Nick
Comment