Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

C Sharp

Posted on 2014-11-21
2
Medium Priority
?
144 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
2 Comments
 
LVL 41

Accepted Solution

by:
Kyle Abrahams earned 2000 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

 [eBook] Windows Nano Server

Download this FREE eBook and learn all you need to get started with Windows Nano Server, including deployment options, remote management
and troubleshooting tips and tricks

Question has a verified solution.

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

Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
We’ve all felt that sense of false security before—locking down external access to a database or component and feeling like we’ve done all we need to do to secure company data. But that feeling is fleeting. Attacks these days can happen in many w…
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses

971 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