I have what is hopefully a simple, newbie issue to resolve. I have some code that opens a new email in the default client, if it exists. I don't need to actually send the email (hence no addressing) just open a new message and populate subject and body. The code below works fine in every way except in the text body the newlines are ignored so its all on one continuous line. I have tried splitting the text by line feed (which is successful) and then building up while appending vbCrLf to each, but still no joy.
(frmMain.txtBody is a RichTextBox, and DNFileName is a string that may or may not be present)
The only issue i need to resolve is the newlines. Help!
(frmMain.txtBody is a RichTextBox, and DNFileName is a string that may or may not be present)
The only issue i need to resolve is the newlines. Help!
VB.NET:
Sub OpenEmail()
Dim ProcString$ = ""
Dim S$()
Dim myProcess As New Process
'-----------------------------
If Len(DNFileName) > 0 Then ProcString = "&subject=" & DNFileName
ProcString = ProcString & "&body="
S = Split(frmMain.txtBody.Text, ControlChars.Lf)
For i = 0 To UBound(S)
ProcString = ProcString & S(i) & vbCrLf
Next
Try
With myProcess
.StartInfo.FileName = "mailto:" & ProcString
.StartInfo.UseShellExecute = True
.StartInfo.RedirectStandardOutput = False
.Start()
.Dispose()
End With
Catch ex As Exception
MsgBox("Error trying to generate email:" & vbCrLf & Err.Description, 48, c_AppName)
End Try
End Sub