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