sending an email (an easy way)

  • Thread starter Thread starter Josh Golden
  • Start date Start date
J

Josh Golden

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. Kind of like I can do with
mailto:[email protected] in HTML. Since it will be installed on the server
and run over the network I won't be able to install the office PIA on every
users machines. Is there a really simple way to do this?
 
* "Josh Golden said:
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.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?" _
)
///
 
I've tried to use the code listed below, but have run into a problem.

It replaces all spaces in Message and Subject with + signs.

So that something like

Message = "This is the information you requested."

Comes out as

This+is+the+information+you+requested.

In Outlook's message window. This is launching Outlook 2000 SP3 on Windows
XP.

Herfried K. Wagner said:
* "Josh Golden said:
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.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