Solved

C Sharp

Posted on 2014-11-21
2
134 Views
Last Modified: 2014-11-21
Hi guys ,

I have some issue to send email after I implemented this code

            MailMessage mail = new MailMessage();
            mail.To.Add("dataprocessing@althompson.com");
            mail.From = new MailAddress("systeminfo@althompson.com");
            mail.Subject = em.Subject;
            string Body = em.Body;
            mail.Body = Body;
            mail.IsBodyHtml = true;
            SmtpClient smtp = new SmtpClient();
            smtp.Host = "172.16.1.6";
            smtp.Port = 587;
            smtp.UseDefaultCredentials = false;
            smtp.Credentials = new System.Net.NetworkCredential("example@domain.com", "password");
            smtp.EnableSsl = true;
            smtp.Send(mail);
            return View();

Open in new window


the issue is in my credential
 smtp.Credentials = new System.Net.NetworkCredential("example@domain.com", "password");
actually in my case exchange server I have to type credential in this way below:

 smtp.Credentials = new System.Net.NetworkCredential("domain\example", "password");

when I type this way I get some error - unrecogniz escape sequence.


I need to know how can I type my user like domain\example without getting this error.
0
Comment
Question by:Moti Mashiah
[X]
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
2 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 40457882
To fix that:
 smtp.Credentials = new System.Net.NetworkCredential("domain\\example", "password");

You need 2 backslashes to = 1 backslash.  the \ by itself is an escape character, meaning put the next literal in.
0
 
LVL 1

Author Closing Comment

by:Moti Mashiah
ID: 40458136
Thank you very much that solved my problem.
0

Featured Post

Salesforce Has Never Been Easier

Improve and reinforce salesforce training & adoption using WalkMe's digital adoption platform. Start saving on costly employee training by creating fast intuitive Walk-Thrus for Salesforce. Claim your Free Account Now

Question has a verified solution.

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

More often than not, we developers are confronted with a need: a need to make some kind of magic happen via code. Whether it is for a client, for the boss, or for our own personal projects, the need must be satisfied. Most of the time, the Framework…
This article is for Object-Oriented Programming (OOP) beginners. An Interface contains declarations of events, indexers, methods and/or properties. Any class which implements the Interface should provide the concrete implementation for each Inter…
Are you ready to implement Active Directory best practices without reading 300+ pages? You're in luck. In this webinar hosted by Skyport Systems, you gain insight into Microsoft's latest comprehensive guide, with tips on the best and easiest way…

710 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