473,387 Members | 3,810 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,387 software developers and data experts.

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.Diagnostics.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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Dim oProcess As New Process
oProcess.StartInfo.FileName = "MailTo:" + tbemail.Text
oProcess.StartInfo.Arguments = ""
' This will allow the Exited event to fire.
oProcess.EnableRaisingEvents = 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(ByVal 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(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles Button4.Click
Dim oProcess As New Process
' Provide the name of the application or file.
oProcess.StartInfo.FileName = "Noteopad"
' Specify the arguments.
oProcess.StartInfo.Arguments = ""
' This will allow the Exited event to fire.
oProcess.EnableRaisingEvents = 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(ByVal 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 2125

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

Similar topics

12
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...
1
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...
1
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...
1
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...
2
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...
0
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...
4
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...
4
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...
0
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...
39
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'...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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,...
0
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...

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.