Launch Email with Process.Start

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)
 
C

Crouchie1998

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top