! and spaces added to email when sending email in .net application

  • Thread starter Thread starter Nicola
  • Start date Start date
N

Nicola

When using the NewMail.Body object, ! and spaces are being added into
the email after the email has been sent. Has anyone else had this
problem or even better a solution??
 
Hi Nicola,

Paste in some code, maybe we can help you?

(When you do that first to the notebook and then copy from there in the
mail, otherwise we get a very long message)

Cor
 
Cor said:
Hi Nicola,

Paste in some code, maybe we can help you?

(When you do that first to the notebook and then copy from there in the
mail, otherwise we get a very long message)

Cor

Cor,
Here's the code to build up email

strLine1 = "<table border='0' cellpadding='0' cellspacing='0'
width='600'>"
strLine2 = "<tr><td width='100%'><p align='right'>Permit
Number......................</p></td></tr>"
strLine3 = "<tr><td width='100%'><p align='right'>Permit
Date...........................</p></td></tr>"
strLine4 = "<tr><td width='100%' align='center'><b>GLASGOW
CITY COUNCIL</b></td></tr>"
strLine5 = "<tr><td width='100%' align='center'><b>LAND
SERVICES</b></td></tr>"
strLine6 = "<tr><td width='100%'
align='center'><b>PERMISSION TO OCCUPY PORTIONS OF A
ROAD</b></td></tr>"
strLine7 = "<tr><td width='100%'>Glasgow City Council in
exercise of their powers under Section 59 of the Roads </td></tr>"
strLine8 = "<tr><td width='100%'>(Scotland) Act 1984 (and
under Section 14 of the Road Traffic Regulation Act 1984) </td></tr>"
strLine9 = "<tr><td width='100%'>hereby grant permission
to :-</td></tr>"
strLine10 = "<tr><td width='100%'>Name:</td></tr>"
strLine101 = "<tr><td width='100%'>" & strName &
"</td></tr>"
strLine11 = "<tr><td width='100%'>Address:</td></tr>"
strLine102 = "<tr><td width='100%'>" & strFlat &
strHouseName & strAddress & "</td></tr>"
strLine12 = "<tr><td width='100%'>Postcode: " & strPcode &
"</td></tr>"
strLine13 = "<tr><td width='100%'>Telephone No.: " &
strPhone & "</td></tr>"
strLine14 = "<tr><td width='100%'>Fax
No.:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;" & strFax &
"</td></tr>"
strLine15 = "<tr><td
width='100%'>E-mail:&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
& strEmail & "</td></tr>"
strLine16 = "<tr><td width='100%'>to place or cause to be
placed a Simon Tower on the carriageway of</td></tr>"
strLine17 = "<tr><td width='100%'>" & strCarriageway &
"</td></tr>"
strLine18 = "<tr><td width='100%'>From " & strDateFrom & "
To " & strDateTo & "</td></tr>"
strLine19 = "<tr><td width='100%'>subject to the
conditions specified in Appendix II and hereby authorise and
require</td></tr>"
strLine103 = "<tr><td width='100%''>the said (Name) " &
strContact & "</td></tr>"
strLine20 = "<tr><td width='100%'>to place on the highway
such traffic signs as may be necessary to comply with the </td></tr>"
strLine21 = "<tr><td width='100%'>conditions of this
permission.</td></tr>"
strLine22 = "<tr><td
width='100%'>---------------------------------------------------------------------------------------------------------------</td></tr>"
strLine23 = "<tr><td width='100%'><font size = '1'>OFFICE
USE ONLY</font></td></tr>"
strLine24 = "<tr><td
width='100%'>Operations_Manager...................................................................Date:......................</td></tr>"
strLine25 = "<tr><td
width='100%'>----------------------------------------------------------------------------------------------------------------</td></tr>"
strLine26 = "<tr><td width='100%'>Appendix I</td></tr>"
strLine104 = "<tr><td width='100%'>Sketch plans showing
proposed location of Crane and details of dimensions with </td></tr>"
strLine105 = "<tr><td width='100%'>outriggers in use.
Permits will be issued with the condition that a plan (if required)"
strLine108 = "<tr><td width='100%'>is provided by post or
fax.</td></tr>"
strLine27 = "<tr><td width='100%'>Appendix II</td></tr>"
strLine106 = "<tr><td width='100%'>Conditions pertaining
to this permission</td></tr>"
strLine109 = "<tr><td
width='100%'>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>"
strLine28 = "<tr><td width='100%'>I hereby agree to comply
with the conditions.</td></tr>"
strLine107 = "<tr><td
width='100%'>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>"
strLine29 = "<tr><td width='100%'>To be signed by
applicant on receipt..............................................</td></tr>"
strLine110 = "<tr><td
width='100%'>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>"
strLine30 = "<tr><td width='100%'><b>AUTHORISATION
STAMP</b></td></tr>"
strLine111 = "<tr><td width='100%'>This certificate must
be shown if requested to a policeman or to any officer of Glasgow City
Council. It is valid only if if carries the Glasgow City Council stamp
of authorisation and it is a condition that the opening be made within
a period of ten days from the date of issue.</td></tr>"
strLine112 = "<tr><td
width='100%'>&nbsp;&nbsp;&nbsp;&nbsp;</td></tr>"
strLine31 = "<tr><td width='100%'>This authorised permit
is to be&nbsp;" & strDelivery & "</td></tr>"
strLine32 = "</table>"

Code for email class
Public Class gccEmail
' public EMail Class for sending an email using information from
form
' The four Parameters to send using SendMail Function are:
' MailFrom - Addree where Email is from (string)
' MailTo - Address where Email to be sent (string)
' MailSubject - Description/Subject of the Email (string)
' MailBody - The Text of the Email (string)
' A true or False Boolean value is returned
'(IF True there is no errors and email is sent IF False there
are errors and no email sent)
Public Shared Function SendMail(ByVal MailFrom As String, ByVal
MailTo As String, ByVal MailSubject As String, ByVal MailBody As
String) As Boolean
Dim NewMail As New MailMessage()
Try
If MailFrom <> "" Then
NewMail.From = MailFrom
ElseIf MailFrom = "" Then
NewMail.From = "(e-mail address removed)"
End If
NewMail.Body = MailBody
NewMail.To = MailTo
NewMail.Subject = MailSubject
NewMail.BodyFormat = MailFormat.Html
NewMail.Priority = MailPriority.Normal


SmtpMail.SmtpServer = "HAHTsitemail"
SmtpMail.Send(NewMail)
Catch
Return False
End Try
Return True
End Function
End Class
 
Hi Nicola,

I see in your message some (incomplete) code to put HTML lines on a webpage.

A normal shared mailfunction, that will be activated by

SendMail(MailFrom, MailTo , MailSubject, MailBody)

With that function I see as far as I can see it now nothing wrong

But there is is a lot of generated HTML code, from what I asume you make
the MailBody, (the code is not there) did you try it with just an empty
body, I think that is the best approach to see it the ! is by the HTML or
just by something else.

Cor
 
Back
Top