473,407 Members | 2,315 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,407 software developers and data experts.

Access hangs inconsistently depending on the machine and debug mode

119 100+
I have the following code in a VBA Access module.

Expand|Select|Wrap|Line Numbers
  1. Declare Function MAPISendMail Lib "Mapi32.dll" _
  2.                               Alias "BMAPISendMail" (ByVal Session&, _
  3.                               ByVal UIParam&, _
  4.                               Message As MAPIMessage, _
  5.                               Recipient() As MapiRecip, _
  6.                               File() As MapiFile, _
  7.                               ByVal Flags&, _
  8.                               ByVal Reserved&) As Long
  9.  
which is called by:

Expand|Select|Wrap|Line Numbers
  1. SendMail = MAPISendMail(0&, 0&, MAPI_Message, MAPI_Recip(), MAPI_File(), MAPI_LOGON_UI, 0)
  2.  
The code sends an email with the required recipients, subject, body and attachements. On one machine, the code works without any problems. On another machine, when run from a form that triggers the code, it hangs at the SendMail line.

However, if I put a break point at the SendMail line and step through the code, I experience no problems.

This seems to be wonderfully inconsistent to me. Has anyone experienced this before or can anyone offer a pointer to resolve this issue?

Many thanks.
Mar 27 '07 #1
5 2516
Denburt
1,356 Expert 1GB
I don't think a new thread was necesary however we are here.

Did you try the two methods I mentioned in the other thread?

I also thought you stated that the sendobject method was working for you?

If I were using Mapi I would add a reference in my VBA window to Outlook once that is done you can use something like the following and this should help you track down your problem. I did a bit of searching and the method you are using does have some issues, I didn't see any definitive work arounds just people poking about.

Expand|Select|Wrap|Line Numbers
  1. Dim appOutLook As Outlook.Application
  2.         Dim MailOutLook As Outlook.MailItem
  3.         Set appOutLook = CreateObject("Outlook.Application")
  4.         Set MailOutLook = appOutLook.CreateItem(olMailItem)
  5.  
You can also use CDONTS to send mail as an alternative.
Mar 29 '07 #2
billelev
119 100+
SendObject did work for me, but I was only able to send snapshot views using this method. I wanted to send files that could be read easily by any user and resorted to pdf reports as that was the best solution I could find. This then moved the problem to creating pdf's and then attaching them to an email, and sending that email. Hence the new post.

I am able to use the pdf method on a couple of machines, but the trouble I describe above occurs on a third machine. It is possible that this machine has some kind of software installation issue, or perhaps the method I am using is prone to instabilities.

This is what I am not sure about.

I have tried the DoEvents and DBEngine.Idle but it did not help, unfortunately. I will look into your suggestions...
Mar 29 '07 #3
ADezii
8,834 Expert 8TB
I have the following code in a VBA Access module.

Expand|Select|Wrap|Line Numbers
  1. Declare Function MAPISendMail Lib "Mapi32.dll" _
  2.                               Alias "BMAPISendMail" (ByVal Session&, _
  3.                               ByVal UIParam&, _
  4.                               Message As MAPIMessage, _
  5.                               Recipient() As MapiRecip, _
  6.                               File() As MapiFile, _
  7.                               ByVal Flags&, _
  8.                               ByVal Reserved&) As Long
  9.  
which is called by:

Expand|Select|Wrap|Line Numbers
  1. SendMail = MAPISendMail(0&, 0&, MAPI_Message, MAPI_Recip(), MAPI_File(), MAPI_LOGON_UI, 0)
  2.  
The code sends an email with the required recipients, subject, body and attachements. On one machine, the code works without any problems. On another machine, when run from a form that triggers the code, it hangs at the SendMail line.

However, if I put a break point at the SendMail line and step through the code, I experience no problems.

This seems to be wonderfully inconsistent to me. Has anyone experienced this before or can anyone offer a pointer to resolve this issue?

Many thanks.
Does the 'hanging machine' have a MAPI complient E-Mail application installed - if not, I imagine the code will fail.
Mar 29 '07 #4
billelev
119 100+
Does the 'hanging machine' have a MAPI complient E-Mail application installed - if not, I imagine the code will fail.
It had Outlook installed.

I have just added the Microsoft Outlook reference on the VBA screen, and the hanging machine now works without any problems.

The weird thing is that the other two machines executed the code without the Outlook reference. Bizarre. And the code on the (now previously) hanging machine would work if I stepped through the code using the debugger.

Thank you all for your help.
Mar 29 '07 #5
Denburt
1,356 Expert 1GB
Glad you got it, just something to think of, I use CDO for most of my exports this allows me to export into an HTML file, then embed the html into the email body, this can also be done using MAPI but I seem to have less trouble with CDO .... However some companies and or people don't allow HTMl messages in the emails so it can lose some structuring when that happens. Fortunately at this company no one has complained so I think they all have HTML email bodies turned on.

My code for CDO is a bit extensive but here is a snippet of one where I used MAPI:

Expand|Select|Wrap|Line Numbers
  1. Set ol = CreateObject("Outlook.Application")
  2. Set ns = ol.getNamespace("MAPI")
  3. ns.logon "", "", True, False
  4. Set iMsg = ol.CreateItem(olMailItem)
  5.  Set ts = FSO.OpenTextFile(Application.CurrentProject.Path & "\InvLG.HTML", ForReading, True) '.CreateTextFile(vFile)
  6.  tsR = ts.ReadAll
  7.  
  8. With iMsg
  9. .HTMLBody = tsR
  10.  
  11.  
Hope all goes well any more questions let us know.
Mar 30 '07 #6

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

Similar topics

11
by: anuradha.k.r | last post by:
hi, i am writing a socket program in python,both client side and server side.I've written the client side which is working perfectly fine(checked it against server program written in C).but as for...
2
by: Philip | last post by:
My debugging capabilities within Visual Studio 2003 have stopped working. None of my applications created over the past year will run in debug (F5) mode. I created a simple "Hello World"...
7
by: Sven Schwyn | last post by:
Hi Many people are asking how to automatically update columns containing a modification date on updates. I'm wondering if the only solutions in the current pgsql really are... - adding...
7
by: dog | last post by:
I've seen plenty of articles on this topic but none of them have been able to solve my problem. I am working with an Access 97 database on an NT4.0 machine, which has many Access reports. I...
11
by: Grasshopper | last post by:
Hi, I am automating Access reports to PDF using PDF Writer 6.0. I've created a DTS package to run the reports and schedule a job to run this DTS package. If I PC Anywhere into the server on...
29
by: Patrick | last post by:
I have the following code, which regardless which works fine and logs to the EventViewer regardless of whether <processModel/> section of machine.config is set to username="SYSTEM" or "machine" ...
4
by: Robert Pfeffer | last post by:
Hi, I have a rather unusual problem. I have a very simple ASP.NET application, basically hello world type. I created it with Visual Studio 2003 and am running it in debug mode. It runs fine...
0
by: jeff.dyke | last post by:
I am using ftplib in some code that does exactly what you would expect. It ftp's files. Its running inside a service running on windows xp and windows 2003 servers, approximately 20 installations...
2
by: colin | last post by:
Hi, I seem to have introduced a probem into my application wich cuases the IDE to hang when I switch from debug to reease mode. it doesnt even consume any cpu %, just sits there, with the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.