-1

I need to send an email containing a string like this:

CSAclsEN\t001\t\\\\sgprt\\Projects2\t001\tCSAclsEN-2010-1140609\t10:03\t09JUN14\t2010\tNorth London branch\tGG02\t001\t****09\tCustomer 340509\t\r01\t******35 \tVariable rate Cash ISA\tGBP\t395.08\t\r02\t31MAR14\tInterest\t7.21+\t\t\r01\t******69 \tInstant Access account\tGBP\t0.00\t\r01\t******75 \t35 Day Notice account\tGBP\t412.11\t\r02\t27MAY14\tInterest\t0.22+\t\t\r02\t25APR14\tInterest\t0.21+\t\t\r02\t25MAR14\tInterest\t0.19+\t\t\r02\t25FEB14\tInterest\t0.21+\t\t\r02\t27JAN14\tInterest\t0.28+\t\t\r01\t******76 \t35 Day Notice account\tGBP\t0.00\t

(this is that it can be investigated in the same format it is taken off of the WebSpehere Message Queue.

Unfortunately the SMTP Mail seems to be taking that and turning it into this:

enter image description here

Here is my code:

        SmtpClient emailSender;
        MailMessage theMessage;

        // Connect to the server.
        emailSender = new SmtpClient("sgexc");

        // Build the content details.
        theMessage = new MailMessage();
        theMessage.From = new MailAddress(emailFromAddress, "Cashier Printing System");
        theMessage.Subject = emailSubject;

        string[] toAddresses = emailToAddress.Split(new Char[] { ':' });

        foreach (string toAddress in toAddresses)
            {
            theMessage.To.Add(toAddress);
            }
        string[] ccAddresses = emailCCAddress.Split(new Char[] { ':' });

        //foreach (string ccAddress in ccAddresses)
        //    {
        //    theMessage.CC.Add(ccAddress);
        //    }

        sMessage=sMessage.Replace(@"\","\\");
        theMessage.Body = sMessage;
        theMessage.IsBodyHtml = false;

        // Fill in the details and send.
        emailSender.Send(theMessage);

WHat do I need to do if I want to prevent Outlook or SMTP from parsing those escape sequences? I have tried replacing all the backslashes with 2 backslashes but no luck.

Etheryte
  • 20,940
  • 10
  • 58
  • 98
Our Man in Bananas
  • 5,467
  • 19
  • 82
  • 136
  • 1
    Actually looks like you want this. Deleted my answer and guess this should be closed as a duplicate. Didn't comprehend exactly what you wanted. http://stackoverflow.com/questions/323640/can-i-convert-a-c-sharp-string-value-to-an-escaped-string-literal – TyCobb Jun 30 '14 at 22:27
  • @TyCobb: I checked, and although **it's awesome** it isn't the answer. From what I can tell, the only thing that works is in my answer below. – Our Man in Bananas Jun 30 '14 at 22:48

1 Answers1

0

I found the answer, and it's very simple.

I just set the theMessage.IsBodyHtml = true;

Our Man in Bananas
  • 5,467
  • 19
  • 82
  • 136