473,414 Members | 1,698 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,414 software developers and data experts.

Mailto Problem

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
Jul 21 '05 #1
2 2276
Possibly this is the garbage collector's fault, but I doubt it.

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

--
Klaus H. Probst, MVP
http://www.vbbox.com/
"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:eU*************@TK2MSFTNGP11.phx.gbl...
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

Jul 21 '05 #2
Klaus;

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

Wayne

"Klaus H. Probst" <us*******@vbbox.com> wrote in message
news:ur**************@TK2MSFTNGP10.phx.gbl...
Possibly this is the garbage collector's fault, but I doubt it.

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

--
Klaus H. Probst, MVP
http://www.vbbox.com/
"Wayne Wengert" <wa***************@wengert.com> wrote in message
news:eU*************@TK2MSFTNGP11.phx.gbl...
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


Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: nAmYzArC | last post by:
Hi everyone, I'm setting the body of an email using values from a form firstname = bob lastname = dole ebody = 'First Name: ' + firstname + '\r\n' + 'Last Name: ' + lastname ...
6
by: Tom | last post by:
Anybody know how to modify this script to return to the HTML page from which it was launched? <script language="javascript"> document.location.href="MailTo:"; </script>
4
by: Ciar?n | last post by:
Hi all, I've go a little mailto: link on a page that when clicked opens an email form with the email address in the To field - all very simple. Problem is that in Netscape, a new blank window is...
10
by: Adam Smith | last post by:
How can I set up a mailto with a cc or bcc as well as a subject designation. The system works for two but not three, is this a hardwired limit or have I missed something ==> <a...
4
by: Tero Partanen | last post by:
Hello! I'm writing about a rather peculiar problem I'm having with Access2000. I have a table in which I have created one hyperlink-type field. I have given the field a default value which is...
15
by: tshad | last post by:
I am trying to put an persons email address in a response I am sending another person. I can get it to work by doing the following: message.Body = resumeTop & vbCrLf & vbCrLf & "For Applicant:...
2
by: Paolo | last post by:
While it is not a problem to create a mailto link in HTML, <a href= "mailto: <%# Databinder.Eval(Container.DataItem,"StoreEmail") %>" ><%#DataBinder.Eval(Container.DataItem,...
11
by: mike_solomon | last post by:
Hi I have a link on a website that if you click opens up outlook <button onClick="location.href='mailto:a@b.com?subject=test subject'" > Select</button> Works fine But I want to include...
5
by: Joh | last post by:
I'm using mailto to open up an email that have a hyperlink in the body. The hyperlink passes two variables Name and Emailadress. The problem is that only the first variable Name show up in the...
2
by: Marc | last post by:
I have a button that when clicked, makes a database call to retrieve some data. That data is used to generate a series of e-mail addresses that I then want pre-populated into an Outlook e-mail. I...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.