Mailto Problem

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
 
K

Klaus H. Probst

Possibly this is the garbage collector's fault, but I doubt it.

Try passing the object to GC.KeepAlive() and see if that helps.
 
W

Wayne Wengert

Klaus;

Interesting idea but it did not help. Thanks for the suggestion.

Wayne
 

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