473,465 Members | 1,912 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

CreateProcess and waitforsingleobject, with outlook.

Hi I am trying to open an email in outlook with the following

string command = "c:\\Program Files\\Microsoft
Office\\OFFICE11\\OUTLOOK.EXE c:\\a.msg";
StartupInfo si = new StartupInfo();
ProcessInformation pi = new ProcessInformation();
si.cb = 68; //sizeof(si);
try {
int i = CreateProcess(null, command, 0, 0, false, 0, 0,
null, si, pi);
Int32 INFINITE;
unchecked { INFINITE = (int)0xFFFFFFFF; }
IntPtr f = new IntPtr(pi.hProcess);

WaitForSingleObject(f, INFINITE);

DocumentEventHandler h = DocumentClosedEvent;
if (h != null) h(mDocumentID);
} catch (Exception e) {
Console.WriteLine(e);
}

basically i want to open the email file, wait for the user to close it
then fire an event so i know the document was closed, this works fine
for word docs, powerpoint, sometimes works for pdf, but for outlook it
doesnt, unless outlook is fully closed and i do it. I have also tried
using the System.Diagnostics.Process, with the wait, and it has the
same effect.

Has anyone got a solution to my problem i am going crazy with this and
need it solved asap. I have also tried looking at the processes on the
system and their threads and checking if any match the id processinfo
has, but to no avail.

Please if someone can help me out here it would be appreciated.

Thanks

Jul 11 '06 #1
1 6007
st***********@gmail.com wrote:
Int32 INFINITE;
unchecked { INFINITE = (int)0xFFFFFFFF; }
You know about Timeout.Infinite, right? And that "-1" is just as good?
basically i want to open the email file, wait for the user to close it
then fire an event so i know the document was closed, this works fine
for word docs, powerpoint, sometimes works for pdf, but for outlook it
doesnt, unless outlook is fully closed and i do it.
That's probably because the new process quits as soon as it's informed
the existing Outlook instance of the request.
Has anyone got a solution to my problem
I think you need to look into Office Interop and manipulating Outlook
with COM, but I haven't done what you're trying to do. Just a
suggestion.

-- Barry

--
http://barrkel.blogspot.com/
Jul 11 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: ByteSize | last post by:
Would be grateful of advice please. I have code in VB6 working as follows: lngReply = CreateProcess(sNull, txtStart, ByVal 0&, ByVal 0&, 1&, _ NORMAL_PRIORITY_CLASS, ByVal 0&, sNull, sInfo,...
1
by: DOT NET JIM | last post by:
in VB6 the api declares the createprocess lbEnv var as any. When converted to ..NET is change the type any to Object. The problem is, what kind of object. I can not get the env variables set when...
0
by: Girish NS | last post by:
Hi, I 'm trying to start mlcfg32.cpl thru CreateProcess(). The .cpl file is in C:\Program Files\Common Files\System\Mapi\1033 folder instead of C:\WINNT\system32 where the default control panel...
5
by: Stefano Camaiani | last post by:
Hello, please someone have the working code on how to call the CreateProcess API in Vb.Net? I need to call the CreateProcess API directly and i should not use the Vb.Net Process functions like dim...
2
by: Paul Schenk | last post by:
Hi All :) Would be grateful of advice please. I have code in VB6 working as follows: lngReply = CreateProcess(sNull, txtStart, ByVal 0&, ByVal 0&, 1&, _ NORMAL_PRIORITY_CLASS, ByVal 0&,...
1
by: Jai | last post by:
Please provide sample code for using Createprocess in VB.NET. The code I am using is given below. But I get "Error 91: Object referrence not set to an instance of the object" at CreateProcess...
3
by: stefan.sedich | last post by:
Hi im trying to open a saved email in outlook, im using createprocess, to open outlook and pass the saved email as an argument, my problem is, im trying to wait until the process ends so my program...
3
by: wtfdan | last post by:
When I call the method perform_single_upload() in this loop: ---------------------------- private: System::Void start_uploads(int i) { i = 0; while(i < master_list->Length) { //Create a...
10
by: blisspikle | last post by:
I see a lot of examples posted for Waitforsingleobject API for Processes or threads, but not events. I cannot get waitforsingleobject to subscribe to an event. I use a class PLCEthernet which is...
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
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,...
1
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
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
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...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.