Characters appearing in email sent via SMTP

Posted on 2006-11-05
Last Modified: 2010-04-07

I've written an application for my company that will send an automated email when a certain condition has been met. The text for these emails originates from a text file. When the email has been sent and arrives in a users mail box, an exclamation mark appears at approximately character 990.

I've done a test just sending the characters 1234567890 and its nothing to do with the text file, and I've played with bodyencoding and bodyformat to no avail. Any ideas?

       With CfH_Message
            .From = From
            .To = To
            .Subject = Subject
            .Body = Message
            .BodyFormat = MailFormat.Html
            .BodyEncoding = System.Text.Encoding.Default
        End With
        SmtpMail.SmtpServer = ConfigurationSettings.AppSettings("SMTPServerAddress")

using the 1234567890 the results are as below (note the ! towards the end). The ! does NOT appear in the text email message. The proper text is in the form of a Dear Jo Bloggs email to a user, who happened to notice the exclamation mark towards the end of the email amongst various words (depending on the email). How has it appeared? This has been added AFTER the smtpmail.send. How can it be cured?

12345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123456789! 01234567890
Question by:obyapka
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 3
LVL 12

Expert Comment

ID: 17879012
Try this:
.BodyEncoding = MailFormat.Base64

Author Comment

ID: 17879880
MailFormat.Base64 does not appear as an option - only .HTML and .TEXT appear.

btw I'm using ASP.NET v1.1

Author Comment

ID: 17879910
MailEncoding.Base64 exists but setting .BodyEncoding to this results in
"Value of type 'System.Web.Mail.MailEncoding' cannot be converted to 'System.Text.Encoding"

I'm using Imports System.Web.Mail, allowing me to do  Dim Cfh_Message As New MailMessage

examples that I've seen on the net that use MailEncoding.Base64 appear to use System.Web.Util, but if I use this I cannot create a mail object as above!!! (Type MailMessage is not defined). Grrrrr

LVL 15

Accepted Solution

crisco96 earned 125 total points
ID: 17880139
There's a strange bug where if you have a string of length 512 or more without a line break random exclamation points appear in the email body. Add some code to insert a line break every 400-500 characters.

Author Comment

ID: 17886089
I discovered a similar idea - see - need to do a vbcrlf after every paragraph - I've applied a patch and it appears to work!! :-)

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Form Data Disappears Using Back Button 4 16
Adding items to a C# list incrementally 5 62
Running powershell scripts from ASP.NET 6 58
Why use this lambda? 12 63
Just a quick little trick I learned recently.  Now that I'm using jQuery with abandon in my applications, I have grown tired of the following syntax:      (CODE) I suppose it just offends my sense of decency to put inline VBScript on a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

749 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question