You can use '\n' and '\r' instead of all that messy CHAR(13) business.
The common windows scheme is to have a \r\n.
If your messages are being sent as html (You didn't say) then you will need a <br/> wherever you want a new line to occur. Also, if it's html, a bunch of spaces will be condensed into a single space. You will need to use like to get extra spaces.
But I would first ensure that your emails are being sent as plain text.
Hi Plater,
I am Sending the mail as html only if the option IsHtml is ticked in my application. Can you plz tell me how to use (Or set ) the message.Body.Format to "Plain/Text". Actually the code is as follows, here i am replacing each "\r\n" i.e. "vbCrLf" with 2 vbCrLf's, then i was getting the mail in correct format.
the code is as follows..
Public Sub Send(ByVal strServerName As String, ByVal strUserName As String, ByVal strPassword As String)
Dim msg As System.Net.Mail.MailMessage
Dim objSMTP As New System.Net.Mail.SmtpClient(strServerName)
Dim oAttachments As Attachment
Dim arrTmp As Array
Try
If mIntId <> 0 Then
If mDtNextRetry.TimeOfDay <= System.DateTime.Now.TimeOfDay Then
Try
msg = New System.Net.Mail.MailMessage(mStrFrom, CStr(mStrTo), CStr(mStrSub), mStrBody)
If mStrCC <> "" Then
arrTmp = Split(mStrCC, ";")
For Each strCC As String In arrTmp
If strCC <> "" Then
msg.CC.Add(New MailAddress(strCC))
End If
Next
End If
If mStrBcc <> "" Then
arrTmp = Split(mStrBcc, ";")
For Each strBcc As String In arrTmp
msg.Bcc.Add(New MailAddress(strBcc))
Next
End If
msg.IsBodyHtml = mBlnIsHtml
msg.BodyEncoding = System.Text.UTF8Encoding.UTF8
msg.DeliveryNotificationOptions = Net.Mail.DeliveryNotificationOptions.OnFailure
For Each strAttachment As String In mColAttachment
oAttachments = New Attachment(strAttachment)
msg.Attachments.Add(oAttachments)
Next
objSMTP.Credentials = New System.Net.NetworkCredential(strUserName, strPassword)
objSMTP.DeliveryMethod = SmtpDeliveryMethod.Network
msg.Body = msg.Body.Replace(vbCrLf, vbCrLf + vbCrLf)
objSMTP.Send(msg)
mIntStatus = MailStatus.Sent
mDtSentOn = System.DateTime.Now
Catch ex As Exception
mIntAttempt = mIntAttempt + 1
If mIntAttempt = 3 Then
mIntStatus = MailStatus.UnSendable
Else
mIntStatus = MailStatus.ErrorInMail
End If
mDtNextRetry = System.DateTime.Now.Date.Add(System.DateTime.Now.T imeOfDay).AddHours(2)
mDtSentOn = CDate("1-1-1900")
End Try
UpdateMail()
End If
End If
Catch ex As Exception
Throw ex
End Try
End Sub
Can u suggest me is anything is wrong inthis code?
Thanks
Deepak