473,775 Members | 2,338 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Can't Catch "MailTo:" exit (VB.NET).

Hi All,

I'm new to this so please correct me if I'm wrong. I have written a
small program which holds details for task information. the program
holds an email address, i created a button which use
System.Diagnost ics.Process class in vb.net to start a "Mailto:" + email
address. This works fine, however I wanted to expand on this some more
when the user had sent the email I wanted to do something afterwards.
so looked around and found some code which raises an exit event when
the original event has exited. It works fine when launching something
like notepad.exe, but when I put my mailto command in it does not fire
the exit event. Below I have included the code working and the code not
working.

In advance thanks,

Pete.
Will not work with the below code:

Private Sub Button4_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button4.Click
Dim oProcess As New Process
oProcess.StartI nfo.FileName = "MailTo:" + tbemail.Text
oProcess.StartI nfo.Arguments = ""
' This will allow the Exited event to fire.
oProcess.Enable RaisingEvents = True
' Add an event handler for this process.
' Run the OnProcessExit sub when this process exits.
AddHandler oProcess.Exited , AddressOf OnProcessExit
' Start the process.
oProcess.Start( )

End Sub
Private Sub OnProcessExit(B yVal sender As Object, ByVal e As
EventArgs)
' Avoid late binding and Cast the Object to a Process.
Dim proc As Process = CType(sender, Process)
' Write the ExitCode
Debug.WriteLine (proc.ExitCode)
' Write the ExitTime
Debug.WriteLine (proc.ExitTime. ToString)
MessageBox.Show ("exited")
End Sub
End Class

Will work with the below code:

Private Sub Button4_Click(B yVal sender As System.Object, ByVal e As
System.EventArg s) Handles Button4.Click
Dim oProcess As New Process
' Provide the name of the application or file.
oProcess.StartI nfo.FileName = "Noteopad"
' Specify the arguments.
oProcess.StartI nfo.Arguments = ""
' This will allow the Exited event to fire.
oProcess.Enable RaisingEvents = True
' Add an event handler for this process.
' Run the OnProcessExit sub when this process exits.
AddHandler oProcess.Exited , AddressOf OnProcessExit
' Start the process.
oProcess.Start( )

End Sub
Private Sub OnProcessExit(B yVal sender As Object, ByVal e As
EventArgs)
' Avoid late binding and Cast the Object to a Process.
Dim proc As Process = CType(sender, Process)
' Write the ExitCode
Debug.WriteLine (proc.ExitCode)
' Write the ExitTime
Debug.WriteLine (proc.ExitTime. ToString)
MessageBox.Show ("exited")
End Sub
End Class

Aug 16 '06 #1
0 2165

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

Similar topics

12
88320
by: Ivan Voras | last post by:
In a code such as: if len(sys.argv) < 2: print "I need arguments!" sys.exit(1) Is sys.exit() really a good choice? Is there something more elegant? (I tried return but it is valid only in a function)
1
8526
by: Guinness Mann | last post by:
Pardon me if this is not the optimum newsgroup for this post, but it's the only .NET newsgroup I read and I'm certain someone here can help me. I have a C# program that checks for an error condition and if it finds it it notifies the user with a MessageBox and then on the next line of code (example in a minute) it calls Application.Exit(). To my astonishment, I stepped through the code with the debugger, and watched it call...
1
1286
by: | last post by:
I created a visual basic.net exec on an xp machine and tried to run it on a 98 machine. The program works perfectly on the xp machine.The program starts okay but when I click in a command button I get an exception error. "system io file not found exception. File or assembly name microsoft visualbasic compatibility or one of its dependencies not found." What file(s) does the 98 machine need in order for this program to run ????
1
1985
by: m.ahrens | last post by:
Hi All I try to build a system that monitors xls files. how is it possible to notice if someone cloeses an excel file?is there an event i can connect on or something? (i will develop the system with visual studio .net c#) aditionally i know what the filename is and i also know what the userid is. if someone could show me an example that would be nice. thanks for your help
2
1535
by: Tris | last post by:
Apologies if this is the wrong forum for this question. Could anyone explain why this exception code is not working? The exception is thrown, but then reported as unhandled. The try catch in Main seems to be being ignored??? The exception being reported is a generic System.Exception, nothing exotic. This is only an illustration by the way :)
0
1471
by: zee | last post by:
System.FormatException: Input string was not in a correct format. I am inputting into a databse the value that causes an error is a double, If I leave that field blank then I catch the exception it doesnt instead I get the above error. Why cant I catch this exception? zee *** Sent via Developersdex http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
4
1803
by: bienwell | last post by:
Hi all, I'd like to use TRY, CATCH to open my database connection. I have 2 servers that have the same table name "myTable". If the first connection to Server1 is failed, then the program will try to connect to Server2. Can I have the secong Try inside the first Catch for this purpose ?. Please take a look on my code and fix it if possible. Actually with this code, the database connection with Server2 is opened after the first...
4
10860
by: Bob Day | last post by:
Using VS 2003, VB.net... I am confused about the Application.Exit method, where the help states "This method does not force the application to exit." Aside from the naming confusion, how do I force the application to exit? See **** below for my comments/questions in a simple example. ****In Sub Main, the Application.Exit works as expected, other sub main code is ignored, and when the end sub is reached the application shuts down....
0
1315
by: Cwappy | last post by:
I have a class that builds a DataTable and then, when the process is exiting, tries to write that DataTable to SQL Server 2000 via the SqlBulkCopy class. I know the process is exiting because I'm catching the ProcessExit event (this is a console app). The problem is that calling WriteToServer as seen below will immediately exit the program WITHOUT generating any exceptions or any other notices, including if I step through the code...
39
2822
by: mathieu | last post by:
Hi there, I am trying to reuse a piece of code that was designed as an application. The code is covered with 'exit' calls. I would like to reuse it as a library. For that I renamed the 'main' function into 'mymain', but I am stuck as to what I should do for the 'exit'. AFAIK there is no portable way to catch the exit. The only thing I can think of is atexit, but that does not work since 'exit' is still called afterward.
0
10267
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10106
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10046
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9915
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7463
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5358
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
4014
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 we have to send another system
2
3611
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2852
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.