W
Wayne Wengert
I am using a Sub (see below) to call the default mail application and pass a
list of email addresses and a subject. Most of the time this works perfectly
but occasionally I get an error ("System NullReferenceException: Object
reference not set to an instance of an object"). From what I've been able to
determine, this occurs when there is a username (left of the @) with a
period such as (e-mail address removed)). Has anyone seen this type of problem
and have suggestions on how to resolve it?
================ Code =====================
Public Sub StartDefaultMail( _
ByVal [To] As String, _
Optional ByVal Subject As String = "" _
)
Try
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.FileName = _
"mailto:" & System.Web.HttpUtility.UrlEncode([To]) & _
"?subject=" & Subject
Process.Start(psi)
Catch ex As Exception
MsgBox("Exception: " & ex.ToString, MsgBoxStyle.Information, "Error")
Throw _
New Exception( _
"Default mail client could not be started.", _
ex _
)
End Try
End Sub
list of email addresses and a subject. Most of the time this works perfectly
but occasionally I get an error ("System NullReferenceException: Object
reference not set to an instance of an object"). From what I've been able to
determine, this occurs when there is a username (left of the @) with a
period such as (e-mail address removed)). Has anyone seen this type of problem
and have suggestions on how to resolve it?
================ Code =====================
Public Sub StartDefaultMail( _
ByVal [To] As String, _
Optional ByVal Subject As String = "" _
)
Try
Dim psi As New ProcessStartInfo
psi.UseShellExecute = True
psi.FileName = _
"mailto:" & System.Web.HttpUtility.UrlEncode([To]) & _
"?subject=" & Subject
Process.Start(psi)
Catch ex As Exception
MsgBox("Exception: " & ex.ToString, MsgBoxStyle.Information, "Error")
Throw _
New Exception( _
"Default mail client could not be started.", _
ex _
)
End Try
End Sub