Home > Net >  SmtpClient. Send email thing, email continuous Spaces are consolidated into one, to solve!
SmtpClient. Send email thing, email continuous Spaces are consolidated into one, to solve!

Time:04-10

Email with SmtpClient, expectation effect is mail Body can show multiple consecutive Spaces,
Code:
 

Using System.Net.Mail;
.
Public class SmtpHelper: SmtpClient
{
.

Public string Send (string subject,
String body,
Bool isBodyHtml,
MailAddress from,
MailAddress replayTo,
List The to,
List Cc,
List BCC,
MailPriority priority,
List Attachments)
{
MailMessage message=new MailMessage ();
.
Message. The Body="three blanks: []";
Message. BodyEncoding=System. Text.. Encoding UTF8;
.

This. Send (message);


Invoke the SmtpClient Send (message) method, the result E-mail sent out, Spaces can be automatically merged into one,
The effect of the email sent to:
"Three blanks: []"

Try to use escape:
Message. The Body="three blanks: [& amp; have spent & amp; have spent & amp; have spent] ";

The effect of the email sent to:
Three blanks: [& amp; have spent & amp; have spent & amp; have spent]

Mail contents of continuous space is meaningful for the user, to have no the SmtpClient, really depressed, the great god of all stripes have a solution?



  •  Tags:  
  • C#
  • Related