473,385 Members | 1,730 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,385 software developers and data experts.

Newline in body text of e-mail message using mailto

I am using mailto to open the default e-mail program on the users machine
using the following function code snippet that I found on th web.:-

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
bAns = False
End Try
Return bAns
End Function

All that I want to be abl to do is to place newline characters into the Body
area of the text. I thought that this would be simple, but nothing that I
have tried seems to work! Can anyone help please??

Many thanks

Paul Bromley
Nov 20 '05 #1
7 15835

"Paul Bromley" <fl*******@dsl.pipex.com> wrote in message
news:eR*************@TK2MSFTNGP11.phx.gbl...
All that I want to be abl to do is to place newline characters into the Body area of the text. I thought that this would be simple, but nothing that I
have tried seems to work! Can anyone help please??


%0d%0a
Nov 20 '05 #2
Hi Paul,

Why not use this one.

\\\by Fergus Cooney & small correction Cor
'A reference to System.Web may be necessary
'in the Project for this Import to work.
Imports System.Web.HttpUtility
Public Sub StartDefaultMail (sTo As String, _
Optional sSubject As String = "", _
Optional sMessage As String = "")
Try
sTo = UrlEncode (sTo)
sSubject = sSubject
sMessage = sMessage
Process.Start ("mailto:" & sTo & "?subject=" _
& sSubject & "&body=" & sMessage)
Catch e As Exception
MsgBox ("Couldn't start default email application" _
& vbCrLf & e.Message)
'or
Throw New Exception ("Couldn't start default email app", e)
End Try
End Sub
///

(As Herfried tested is possible that sSubject = sSubject can be needed as
sSubject = UrlEncode(sSubject) the same with the sMessage that you have to
try yourself)

I hope this helps a little bit?

Cor
Nov 20 '05 #3
Excuse my ignorance Jeff, but does %0d%0a go in as part of a string??

Best wishes

Paul Bromley

"Jeff Johnson" <i.***@enough.spam> wrote in message
news:OV**************@TK2MSFTNGP09.phx.gbl...

"Paul Bromley" <fl*******@dsl.pipex.com> wrote in message
news:eR*************@TK2MSFTNGP11.phx.gbl...
All that I want to be abl to do is to place newline characters into the

Body
area of the text. I thought that this would be simple, but nothing that I have tried seems to work! Can anyone help please??


%0d%0a

Nov 20 '05 #4
Hi Cor,

sMessage = UrlEncode(sMessage) does work, but I now get + instead of a
space, which reading the documentation is correct. I also need to check what
else gets changed. I was hoping to use this to send details re ini files for
my application, and for sendin details of the PC spcifciation.

Best wishes
Paul Bromley


"Cor Ligthert" <no**********@planet.nl> wrote in message
news:eT**************@TK2MSFTNGP09.phx.gbl...
Hi Paul,

Why not use this one.

\\\by Fergus Cooney & small correction Cor
'A reference to System.Web may be necessary
'in the Project for this Import to work.
Imports System.Web.HttpUtility
Public Sub StartDefaultMail (sTo As String, _
Optional sSubject As String = "", _
Optional sMessage As String = "")
Try
sTo = UrlEncode (sTo)
sSubject = sSubject
sMessage = sMessage
Process.Start ("mailto:" & sTo & "?subject=" _
& sSubject & "&body=" & sMessage)
Catch e As Exception
MsgBox ("Couldn't start default email application" _
& vbCrLf & e.Message)
'or
Throw New Exception ("Couldn't start default email app", e)
End Try
End Sub
///

(As Herfried tested is possible that sSubject = sSubject can be needed as
sSubject = UrlEncode(sSubject) the same with the sMessage that you have to
try yourself)

I hope this helps a little bit?

Cor

Nov 20 '05 #5

"Paul Bromley" <fl*******@dsl.pipex.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl...
Excuse my ignorance Jeff, but does %0d%0a go in as part of a string??


Check out the examples:

http://msdn.microsoft.com/library/de...asp?frame=true
Nov 20 '05 #6
Thanks for that Jeff, should have tried it before asking. It is part of the
string. I have taken my sBodyText or whatever and done a replace on the text
replacing the relevant return characters with "%0d%0a" prior to calling
mailto. Many thanks for this.

Paul Bromley

"Jeff Johnson [MVP: VB]" <i.***@enough.spam> wrote in message
news:O$**************@TK2MSFTNGP09.phx.gbl...

"Paul Bromley" <fl*******@dsl.pipex.com> wrote in message
news:%2****************@tk2msftngp13.phx.gbl.
Excuse my ignorance Jeff, but does %0d%0a go in as part of a string??
Check out the examples:

http://msdn.microsoft.com/library/de...asp?frame=true

Nov 20 '05 #7
I had the same issue you did (turning all spaces in the body to + signs) so
I just do a string.replace to turn the +'s into %20, which works fine for my
application, because I know there will never be a + sign in a valid email.
Private Sub CreateEmailMessage(ByVal Address As String, ByVal Subject As
String, ByVal Body As String)

Dim psi As New ProcessStartInfo

Dim tempPath As String

psi.UseShellExecute = True

'kludge to fix UrlEncode turning all spaces into + signs.

tempPath = "mailto:" & HttpUtility.UrlEncode(Address) & "?subject=" &
HttpUtility.UrlEncode(Subject) & "&body=" & HttpUtility.UrlEncode(Body)

psi.FileName = tempPath.Replace("+", "%20")

Process.Start(psi)

End Sub

"Paul Bromley" <fl*******@dsl.pipex.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
Hi Cor,

sMessage = UrlEncode(sMessage) does work, but I now get + instead of a
space, which reading the documentation is correct. I also need to check what else gets changed. I was hoping to use this to send details re ini files for my application, and for sendin details of the PC spcifciation.

Best wishes
Paul Bromley

Nov 20 '05 #8

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

Similar topics

3
by: Matt Adams | last post by:
As well known I could specify the text color in the body tag like: <BODY TEXT=WHITE LINK=WHITE VLINK=RED ALINK=WHITE> What I want to achieve now is that always (!) the text of the last visited...
5
by: sanj | last post by:
Hi all, My site is located at: http://www.eastdayspa.com/index.html I have use these main styles /* main styles */
18
by: fleemo17 | last post by:
My organization is developing a set of "standards" for websites built inhouse. The first question that comes to mind is what would be a good standard default size for <p> text? 12 point? Which...
5
by: Park | last post by:
In the multiple line textbox, is it possible that every sentences shows different color ? For example, test sentence 1 : red test sentence 2 : blue ....
29
by: runningdog | last post by:
Hi, I would like to be able to embed a newline in a text string. Is there any convienent notation to do this TIA Steve
3
by: amruta | last post by:
When Iam doing the following: TextBox19.Text &= objReq.Name & ControlChars.Tab TextBox19.Text &= objReq.Number & ControlChars.Tab TextBox19.Text &= objReq.Owner & ControlChars.NewLine ...
4
by: Jeff Higgins | last post by:
Hi, I would like to left align the text within a paragraph element while keeping the paragraph center aligned within the body. The following doesn't do it. Any help will be greatly...
1
by: sherifffruitfly | last post by:
Hi, I get usage statistics emailed to me weekly, and would like to analyze the numbers. How can I read the body text of these emails into, say, a String instance? Thanks, cdj
1
by: sherifffruitfly | last post by:
Anyone know how this can be done? thanks, cdj
2
by: Rishabh Indianic | last post by:
Hi, i display some text in web browser control from my xml file. now i want to search specific word in web browser control and highlight that text. to do this thing i am trying to get text from...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
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
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...

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.