Invoke Email Client

  • Thread starter Thread starter Wayne Wengert
  • Start date Start date
W

Wayne Wengert

I have a Windows application in which users can select one or more
individuals and an email message is created which they then complete and
send. I currently use MAPI for this but I want to change the code to invoke
whatever email client the users has as the default. Any pointers to some
information on how to do this would be appreciated.

Wayne
 
* "Wayne Wengert said:
I have a Windows application in which users can select one or more
individuals and an email message is created which they then complete and
send. I currently use MAPI for this but I want to change the code to invoke
whatever email client the users has as the default. Any pointers to some
information on how to do this would be appreciated.

From 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.Diagnostics
Imports System.Web

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.FileName = _
"mailto:" & HttpUtility.UrlEncode([To]) & _
"?subject=" & HttpUtility.UrlEncode(Subject) & _
"&body=" & HttpUtility.UrlEncode(Message)
Process.Start(psi)
Catch ex As Exception
Throw _
New Exception( _
"Default mail client could not be started.", _
ex _
)
End Try
End Sub
///

Usage:

\\\
StartDefaultMail( _
"(e-mail address removed)", _
"Invitation", _
"Do you want to come to my party?" _
)
///
 
Back
Top