Invoke standard mail client

  • Thread starter Thread starter John Lafrowda
  • Start date Start date
J

John Lafrowda

Hello experts,

I'm coding a routine which should open a new mail form of the mail standard
mail client installed on a system (e.g. outlook, outlook express, netscape
mail, etc.) for support reasons. The routine should fill in some textual
information. It should, however, not mail the information directly. The user
should be able to check the contents of the mail and he should be able to
edit the mail before sending it.
Consequently, I have the simple question: Is there any method in visual
basic (.net) to force the standard mail client of a machine to open a new
form (like mailto:... in HTML) and fill in some information?

Best regards,

John
 
Hi John,

Not only one more, the most simple one I think is the one I have pasted in
bellow.
When you paste it in your IDE it looks nice again. :-)
It is really easy but complete and therefore it looks now maybe complex.

\\\by Fergus Cooney & small corrections by Cor
'A reference to System.Web may be necessary
'in the Project for this Import to work.
Imports System.Web.HttpUtility

Public Sub StartDefaultMail (sTo As String, _
Optional sSubject As String = "", _
Optional sMessage As String = "")
Try
sTo = UrlEncode (sTo)
sSubject = sSubject
sMessage = sMessage
Process.Start ("mailto:" & sTo & "?subject=" _
& sSubject & "&body=" & sMessage)

Catch e As Exception
MsgBox ("Couldn't start default email application" _
& vbCrLf & e.Message)
'or
Throw New Exception ("Couldn't start default email app", e)
End Try
End Sub
///

I hope this helps a little bit?

Cor
 
* "Cor said:
\\\by Fergus Cooney & small corrections by Cor
'A reference to System.Web may be necessary
'in the Project for this Import to work.
Imports System.Web.HttpUtility

Public Sub StartDefaultMail (sTo As String, _
Optional sSubject As String = "", _
Optional sMessage As String = "")
Try
sTo = UrlEncode (sTo)
sSubject = sSubject
sMessage = sMessage
Process.Start ("mailto:" & sTo & "?subject=" _
& sSubject & "&body=" & sMessage)

Catch e As Exception
MsgBox ("Couldn't start default email application" _
& vbCrLf & e.Message)
'or
Throw New Exception ("Couldn't start default email app", e)
End Try
End Sub
///

Why did the code loose all indentations?
 
Why did the code loose all indentations?

Because I have made my HKW database with a function to do that for me.

:-)

But Fergus also said it was not nice looking what is your opinion?

Cor
 
Cor,

* "Cor said:
Because I have made my HKW database with a function to do that for me.

:-)

But Fergus also said it was not nice looking what is your opinion?

Mhm... I prefer indented code even in newsgroup posts because it makes
reading the code much easier. Just a thought.
 
Thanks for all the replies.
Process.Start("mailto:...") seems to be the easiest solution.

Cheers,

John
 
Public Sub StartDefaultMail(ByVal [To] As String, Optional ByVal Subject
As String = "", Optional ByVal Message As String = "")


Try
Dim psi As New ProcessStartInfo

psi.UseShellExecute = True
'psi.UseShellExecute = False

psi.FileName = "mailto:" & HttpUtility.UrlEncode([To]) & _
"?subject=" & HttpUtility.UrlEncode(Subject) & _
"&body=" & HttpUtility.UrlEncode(Message)

Process.Start(psi)

'-------------------------
Catch ex As Exception
Throw New Exception(ex.Message, ex)
End Try
End Sub

i'm using this function,and it works! my question is:
is it possible to get more information from the outlook template, like
the mail server?
very important!
thank you
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top