Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

C Sharp

Posted on 2014-11-21
2
Medium Priority
?
141 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 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

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

A long time ago (May 2011), I have written an article showing you how to create a DLL using Visual Studio 2005 to be hosted in SQL Server 2005. That was valid at that time and it is still valid if you are still using these versions. You can still re…
This article shows how to deploy dynamic backgrounds to computers depending on the aspect ratio of display
In this video you will find out how to export Office 365 mailboxes using the built in eDiscovery tool. Bear in mind that although this method might be useful in some cases, using PST files as Office 365 backup is troublesome in a long run (more on t…
In this video, Percona Solution Engineer Dimitri Vanoverbeke discusses why you want to use at least three nodes in a database cluster. To discuss how Percona Consulting can help with your design and architecture needs for your database and infras…

688 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