Problem Trying to Invoke Default Email Client

W

Wayne Wengert

I am building an aspx page on which I want to have a button, which when
clicked opens the user's default email component (Outlook, OE, etc.). I
searching the web I found the codes shown below but when I try to use it I
get the error:

Exception Details: System.ComponentModel.Win32Exception: No application is
associated with the specified file for this operation

Any thought on what I am doing wrong here?

Wayne


=============== Sample Code ================
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

Private Sub btnSendEmail_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnSendEmail.Click

StartDefaultMail( _

(e-mail address removed), _

"Enter message body here." _

)

End Sub
 
P

Patrice

Looks like you are running this server side + there is no file named like
that...

I would just use a <a href="mailto:..."> link...

Patrice
 

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

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top