• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 624
  • Last Modified:

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?
0
TheAnvilGroup
Asked:
TheAnvilGroup
  • 3
  • 3
1 Solution
 
joriszwaenepoelCommented:
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)
0
 
TheAnvilGroupAuthor Commented:
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.
0
 
joriszwaenepoelCommented:
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.  
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
TheAnvilGroupAuthor Commented:
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.
0
 
joriszwaenepoelCommented:
If it is the email client that converts the last space character into a linefeed + tab character, then you will have to change it's configuration.

Or try to limit the length of the subject line?
0
 
TheAnvilGroupAuthor Commented:
Will check setting on Exchange server and some other applications are also effected and the Exchange server was recently upgraded.
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now