Launch Email with Process.Start

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to launch the default email client from a procedure, code shown
below. I keep getting the following error:
System.ComponentModel.Win32Exception: An attempt was made to reference a
token that does not exist

What am I missing?

Imports System.Diagnostics

Sub SendMail()

Dim toEmail as string
Dim Subject as string
Dim Body as string
Dim Message as string

toEmail = "(e-mail address removed)"
Subject = "Subject goes here"
Body = "Thanks for playing"

Message = "mailto:" & ToEmail & "?subject=" & Subject & "&body=" & Body
Process.Start(message)
 
Try this:

Dim strTo As String = "(e-mail address removed)"
Dim strSubject As String = "My Subject"
Dim strBody As String = "The Body of the message goes here"

Dim strMessage As String = "mailto:" & strTo & "?subject=" &
strSubject & "&body=" & strBody
System.Diagnostics.Process.Start(strMessage)

The above works fine for me.

Crouchie1998
BA (HONS) MCP MCSE
 
Back
Top