Link to home
Start Free TrialLog in
Avatar of TheAnvilGroup
TheAnvilGroupFlag for United Kingdom of Great Britain and Northern Ireland

asked on

VB.NET generated email subject line contains tabs where spaces should be in Outlook 2007

Dim mail As New MailMessage
mail.Subject = BuildSubject(newsData)
mail.Body = "<table>..data..</table>"
mail.IsHTML = True
'Some other code

Dim smtp As New SmtpClient(_sMTPServer)
smtp.Port = 25
smtp.Send(mail)

    Private Function BuildSubject(ByRef newsData As News) As String
        Dim subject As New StringBuilder

        subject.Append("ALERT - ")
        subject.Append(CStr(newsData.PassengerCount))
        subject.Append(" Traveller" & CStr(IIf(newsData.PassengerCount > 1, "s", "")))
        subject.Append(" present in ")
        subject.Append(newsData.CountryName)
        subject.Append(" - Incident level: " & newsData.IncidentLevel.ToString())
        subject.Append(" - Category: " & newsData.FullCategories)
        subject.Append(" - ")
        subject.Append(newsData.SummHeadline)
        subject.Append(" - ")
        subject.Append(newsData.SearchTypeID.ToString())

        Return subject.ToString
    End Function

When email is received in Outlook 2007 contains the following (note there is a tabl before 'strike' and before 'category'):
ALERT - 5 Travellers present in United Kingdom - Incident level: 2 -      Category: Rail Delays/Disruption - UK: Eurostar running 'normally' despite      strike - Proximity

Please help me in what is causing this and how to I get rid of this. Is this to do with Outlook, the email body text not having html tags or is this due to the colons in the subject line?
Avatar of joriszwaenepoel
joriszwaenepoel
Flag of Belgium image

When you look at the string while debugging in VB.NET, do you have the tabs also?  If so, then you can replace them with

Return subject.ToString().Replace(Chr(9), " "c)
Avatar of TheAnvilGroup

ASKER

There are no tabs in the string, I pasted the string into a hex editor and no 09 (tabs) appeared. I only recieve the tabs (09) when the email is in the Outlook 2007 outbox. The problem is that the spaces are being converted to tabs for some unknown reason.
I've been searching in Google for a while.  This seems to be a problem with a lot of email-clients, not just Outlook.  It only happens for long subject lines.

Also, In Outlook 2007, under Tools, Options, Mail Format (tab), Internet Format ... (button)
there is an option for automatic wrapping in plain text messages.  Maybe this setting has something to do with it?  The default wrapping length seems to be 76 characters.  
The tabs appear a character position 69 and then counting from this position another 71 characters. Knowing this how to I solve this other than changing the email client configuration.
ASKER CERTIFIED SOLUTION
Avatar of joriszwaenepoel
joriszwaenepoel
Flag of Belgium image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Will check setting on Exchange server and some other applications are also effected and the Exchange server was recently upgraded.