473,325 Members | 2,480 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,325 software developers and data experts.

SendObject **Reserved Error** (Fails in Loop)

78
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.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Form_Load()
  2. On Error GoTo Err_Form_Load
  3.  
  4. Dim rst As DAO.Recordset
  5. Dim bkMark As String
  6. Dim stDocName As String
  7. Dim strSendTo As String
  8. Dim strSubject As String
  9. Dim strMessageText As String
  10.  
  11. Set rst = Me.RecordsetClone
  12.  
  13. If rst.EOF Then
  14.  
  15. MsgBox "There is no Email Address for Supplier's in this Branch Report File", vbExclamation, "No e-mail addresses"
  16.  
  17. rst.Close
  18.  
  19. Set rst = Nothing
  20.  
  21. DoCmd.Close acForm, "Email", acSaveYes
  22.  
  23. Exit Sub
  24.  
  25. End If
  26.  
  27. Do While rst.EOF = False
  28. bkMark = rst.Bookmark
  29. Me.Bookmark = bkMark
  30.  
  31. stDocName = "Request for Updated PO Info EMAIL"
  32. strSendTo = rst![EmailAddress]
  33. strSubject = "Wesco Distribution Status Update Report"
  34. strMessageText = "To: " & rst![SupplierName] & vbCrLf _
  35. & "" & vbCrLf _
  36. & "C/O: " & rst![ContactName] & vbCrLf _
  37. & "" & vbCrLf _
  38. & "Attached is a status update report for specific PO line items." & vbCrLf _
  39. & "" & vbCrLf _
  40. & "Please review the attached report and reply back to this email with the requested information." & vbCrLf _
  41. & "" & vbCrLf _
  42. & "If you have any questions or concerns, contact information is located on the attached report." & vbCrLf _
  43. & "" & vbCrLf _
  44. & "Thank you," & vbCrLf _
  45. & "" & vbCrLf _
  46. & "Wesco Distribution Purchasing Department "
  47.  
  48. DoCmd.SendObject acSendReport, stDocName, acFormatRTF, strSendTo, , , strSubject, strMessageText, 0
  49.  
  50. rst.MoveNext
  51.  
  52. Loop
  53.  
  54. MsgBox "All emails have been sent to Suppliers", 0, "Email Complete"
  55.  
  56. rst.Close
  57.  
  58. Set rst = Nothing
  59.  
  60. DoCmd.Close acForm, "Email", acSaveYes
  61.  
  62. Exit_Form_Click:
  63. Exit Sub
  64.  
  65. Err_Form_Load:
  66. MsgBox Err.Description
  67. Resume Exit_Form_Click
  68.  
  69. End Sub
  70.  
Thank you In Advance.

Nick
Apr 4 '08 #1
11 1885
Stewart Ross
2,545 Expert Mod 2GB
Hi again Nick. Having reviewed your code before I can't see anything obvious. I am wondering if there is any chance of having a zero-length e-mail sendto address causing a SENDOBJECT failure? You can guard against this if it is at all likely using an IF:

Expand|Select|Wrap|Line Numbers
  1. IF strSendto = "" then 
  2.   strSubject = "Wesco Distribution Status Update Report"
  3.   strMessageText = "To: " & rst![SupplierName] & vbCrLf _
  4.   & "" & vbCrLf _
  5.   & "C/O: " & rst![ContactName] & vbCrLf _
  6.   & "" & vbCrLf _
  7.   & "Attached is a status update report for specific PO line items." & vbCrLf _
  8.   & "" & vbCrLf _
  9.   & "Please review the attached report and reply back to this email with the requested information." & vbCrLf _
  10.   & "" & vbCrLf _
  11.   & "If you have any questions or concerns, contact information is located on the attached report." & vbCrLf _
  12.   & "" & vbCrLf _
  13.   & "Thank you," & vbCrLf _
  14.   & "" & vbCrLf _
  15.   & "Wesco Distribution Purchasing Department "
  16.   DoCmd.SendObject acSendReport, stDocName, acFormatRTF, strSendTo, , , strSubject, strMessageText, 0
  17. END IF
If this is not likely, one other possibility is that the report you are sending is empty - nothing to report. If this is also unlikely then you are going to have to systematically debug by setting a break point at the start of the loop then stepping line by line through the code until you come across the failure point. You can examine the values of variables or print them to the immediate window (using Debug.Print), and check in particular that all expected values are present.

-Stewart
Apr 4 '08 #2
nspader
78
Thank you for the reply. Both are unlikely because I have set up queries that filter out the possibility of empty fields prior to the loop running.

I did discover something...A little background first.

When I run my reports, I run them by branches. In a given report run I run 2-4 branches. This is selected by a drop down menu on the form prior to the email run. This then generates the data for the email form.

When I send emails for the first branch it sends succesfully everytime. If I then change branches and resend it fails after the first few emails.

However, If I exit out of the DB program and go back in I can send another branch successfully (as if it was the first branch ran). If I try to send another branch it fails after the first few.

Is it possible that something doesnt properly close out after the first run? Is there a code to do a fresh start each time, or something like it?

Any help is appreciated.

NICK
Apr 7 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
Hi Nick. If you could post the code that does the selection and branching bits you mention this would be very helpful. A possibility is indeed that something within the code is not closed properly or set back to a known state when you select the next set of e-mails to generate.

Cheers

Stewart
Apr 7 '08 #4
nspader
78
These selections are down in queries, each building on itself. I am very new to access programing and do not believe there is a "code" persay to post. I would be under the assumption that the problem would be in the code posted. But I am not sure.

I do not know where to find the code you are asking for, since like I say it occurs by queries built off another query.

Please advise.

NICK


Hi Nick. If you could post the code that does the selection and branching bits you mention this would be very helpful. A possibility is indeed that something within the code is not closed properly or set back to a known state when you select the next set of e-mails to generate.

Cheers

Stewart
Apr 7 '08 #5
Stewart Ross
2,545 Expert Mod 2GB
Hi Nick. When queries are created in the query editor there is SQL code created in the background. You will see this if you select View, SQL View from the query editor window. You can copy and paste the query SQL code into these posts (using the [code=sql] code tag to delineate the start of your code).

At this remove I cannot think of more that can be done to assist you without seeing a version of your database.

If it was possible for you to attach a sanitised version of your database as a Zip file I and other contributors could check this out for you.

If you feel you could not post a public copy of the database you could send me a personal message (PM) to obtain my e-mail address and send the DB that way if you prefer. Otherwise I doubt there is much more that can be done for you at present.

-Stewart
Apr 7 '08 #6
nspader
78
I would be happy to attach the DB however I cannot attach a zip file. Any reccomendations on attaching or another way?

Please advise.

Nick
Apr 8 '08 #7
nspader
78
Attached is the DB that I have designed. I have tried to strip it down as much as I can. I have changed two things from my normal db. The first is in my code for sending the email I have changed the option to edit ON so that it will pop up the message and you have to manually press send. The error mentioned occurs in both manners. Also, I have changed the supplier emails to all be my email, that way if they do get sent through to check they will all come to me and not sent to the supplier. I have limited supplier information to just what is needed to run emails.

Please help if possible.

Thank you in advance

Nick
Attached Files
File Type: zip Copy of Status Update MASTER.zip (339.1 KB, 101 views)
Apr 8 '08 #8
Stewart Ross
2,545 Expert Mod 2GB
Hi Nick. I've run the code in the sample DB successfully for all test branches in the sample without any object failures. The e-mails were all placed in my Outlook outbox awaiting send (I did not send them to avoid flooding your e-mail address with the tests!). I could not force a failure condition during my tests.

Anyway, having seen the loop functioning well with repeated branch choices it would not appear to be your code as such that is causing the object failure. It suggests that there is an interaction difficulty between the repeated SendObject requests and the receiving e-mail server - can't think of any reason why offhand, other than potentially tiiming issues (if previous requests are not yet dealt with and the request queue is unable to handle new requests because the previous ones have not yet been processed, for example).

-Stewart
Apr 8 '08 #9
nspader
78
Stewart,

I was curious if you had them autosend, not through outlook but by turning of edit feature. I did state that it through the error either way, but I did not verify that. I apologize. I made the assumption if it occured one way it would occur the other as well. I am sending without edit options. Code set to 0. Just curious if that could have anything to do with it.

As a side note, being new to access DB's and setting this up from scratch, How does it look? From a DB function and coding standpoint.

Thank you for all your help with this.

Nick
Apr 9 '08 #10
nspader
78
One other quick note. Would you know if it could have anything to do with the fact that outlook is set up with an email exchange server?

Thanks

Nick
Apr 9 '08 #11
Stewart Ross
2,545 Expert Mod 2GB
Hi Nick. Your DB is looking good and your code was well-structured. You used a separate form for the filtered e-mails for each branch, and this is not actually necessary (you could open the query directly within your recordset code in the branch selection form instead) but everything appears to work well.

I do have the feeling that the errors you are experiencing relate to the Outlook side of things, and possibly to the e-mail requests continuing to be received before Outlook is ready to act on them. I do not know this for certain, nor do I have a solution to it if it is the cause of the undefined error.

I wish I could assist more, but I'm at a loss to suggest what more you can do. It is possible to use VB to control Outlook from Access (as an Office automation application) instead of using the built-in SendObject method, but this may involve considerably more programming in the short-term.

I think if you tried the DB on a different computer with different e-mail access it would help eliminate whether the Outlook end of things is causing the difficulty or not.

-Stewart
Apr 9 '08 #12

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: Jay Bienvenu | last post by:
I am trying to execute a DoCmd.SendObject command to produce an email message from Access 2000. The command produces the email message, but the To:, CC: and BCC: fields are blank. The subject field...
2
by: alessia | last post by:
Hi, i'm sorry for my bad english but ..i'm italian.. I have a big problem that I don't succeed in resolving on the command sendobjet. I have a query that as resulted a list of addresses e-mail it...
0
by: alessia | last post by:
hi I have found this code in this post...
0
by: Jay Bienvenu | last post by:
I'm having a very strange problem that currently defies explanation. I use the code below to send a status report to a client. The intent is to send the user the report via fax using WinFax and/or...
3
by: Fred Zuckerman | last post by:
Hello All, I had written a quick email procedure for a client that uses DoCmd.SendObject. However they have the SR-1 version of Access 2K. They do not have the SP-3 upgrade. The procedure does...
2
by: Miro | last post by:
I created a field in a db called "Password" If i do that, the Update row command throws an exception error. If I call the field PWord then it works great. Is this a reserved word for an...
2
by: Owen Mac | last post by:
Hello everyone, Is it possible to use an email address from a table and/or query with the Sendobject Method. An email address from my form works fine...what I would like is the 'To:' section be...
0
by: Roy Tong | last post by:
I'm using SendObject to generate an email to a list that I have built up in a string variable from email addresses held in a text field within a table. The string of email addresses looks OK. I...
10
by: nspader | last post by:
I am having trouble with my loop code. The code works very well. However, it only loops through 3 records and then completes without errors. I will post code below. Any help with this would be...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.