W
Wayne Wengert
I am using VB.NET and invoking a function that opens the user's default mail
client with a pre-stored list of email addresses and subject. I find that if
the string containing the list of email addresses is longer than about 250
chars, I get an error complaining that "Object reference not set to an
instance of an object.". If the list of emails is less than about 250 chars,
everything works fine. Does anyone have a solution for this or an
alternative way to invoke a defaoult mail client with a long list of email
addresses (up to 1,000)
I've tried a couple of functions I found on the Internet and they all give
the exact same result. The function I am currently using is listed below.
========================================================
Public Function OpenEmail(ByVal EmailAddress As String, _
Optional ByVal Subject As String = "", _
Optional ByVal Body As String = "") _
As Boolean
Dim bAns As Boolean = True
Dim sParams As String
sParams = EmailAddress
If LCase(Strings.Left(sParams, 7)) <> "mailto:" Then _
sParams = "mailto:" & sParams
If Subject <> "" Then sParams = sParams & _
"?subject=" & Subject
If Body <> "" Then
sParams = sParams & IIf(Subject = "", "?", "&")
sParams = sParams & "body=" & Body
End If
Try
System.Diagnostics.Process.Start(sParams)
Catch ex As Exception
MsgBox("Exception: " & ex.ToString, MsgBoxStyle.Information, "Error")
bAns = False
End Try
Return bAns
End Function
client with a pre-stored list of email addresses and subject. I find that if
the string containing the list of email addresses is longer than about 250
chars, I get an error complaining that "Object reference not set to an
instance of an object.". If the list of emails is less than about 250 chars,
everything works fine. Does anyone have a solution for this or an
alternative way to invoke a defaoult mail client with a long list of email
addresses (up to 1,000)
I've tried a couple of functions I found on the Internet and they all give
the exact same result. The function I am currently using is listed below.
========================================================
Public Function OpenEmail(ByVal EmailAddress As String, _
Optional ByVal Subject As String = "", _
Optional ByVal Body As String = "") _
As Boolean
Dim bAns As Boolean = True
Dim sParams As String
sParams = EmailAddress
If LCase(Strings.Left(sParams, 7)) <> "mailto:" Then _
sParams = "mailto:" & sParams
If Subject <> "" Then sParams = sParams & _
"?subject=" & Subject
If Body <> "" Then
sParams = sParams & IIf(Subject = "", "?", "&")
sParams = sParams & "body=" & Body
End If
Try
System.Diagnostics.Process.Start(sParams)
Catch ex As Exception
MsgBox("Exception: " & ex.ToString, MsgBoxStyle.Information, "Error")
bAns = False
End Try
Return bAns
End Function