* "Josh Golden" <jo***@wachovia .com> scripsit:
hello, In my application I want to send an email when a certain event
ocuurs. It should pop-up the user's email client and fill in the send to
address and subject and body.
My FAQ:
Opening the default mail client with a mail template:
Sample based on work by Fergus Cooney and Cor (mpdl.vb), optimized and
extended by Herfried K. Wagner [MVP]:
Add a reference to "System.Web.dll ". Then you can use this code:
\\\
Imports System.Diagnost ics
Imports System.Web
Public Sub StartDefaultMai l( _
ByVal [To] As String, _
Optional ByVal Subject As String = "", _
Optional ByVal Message As String = "" _
)
Try
Dim psi As New ProcessStartInf o
psi.UseShellExe cute = True
psi.FileName = _
"mailto:" & HttpUtility.Url Encode([To]) & _
"?subject=" & HttpUtility.Url Encode(Subject) & _
"&body=" & HttpUtility.Url Encode(Message)
Process.Start(p si)
Catch ex As Exception
Throw _
New Exception( _
"Default mail client could not be started.", _
ex _
)
End Try
End Sub
///
Usage:
\\\
StartDefaultMai l( _
"fo*@goo.ba z", _
"Invitation ", _
"Do you want to come to my party?" _
)
///
--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>