How to create mail and open using default mail client? (Like PowerToys "Send To")

  • Thread starter Thread starter Ed Sutton
  • Start date Start date
E

Ed Sutton

How can I bring up the users default email client?

My Googling has not turned up anything that does what I need. I need
something that is NOT Outlook specific. Something that works the way
the Micrsoft Power Toys "Send To" extension for "Send to Mail Recipient
MAPI" works. This correctly brings up my Mozilla mail even though I
have Outlook Express.

I need to set the subject and add an attachment.

Thanks in advance for any tips or suggestions,

-Ed
 
How can I bring up the users default email client?

Never mind. I just found the following article on MSDN that does what I
need:

Q315653 - SAMPLE: SimpleMAPIAssembly Demonstrates Use of Simple MAPI
from a .NET Application
 
* Ed Sutton said:
How can I bring up the users default email client?

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