Solved

C Sharp

Posted on 2014-11-21
2
113 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 39

Accepted Solution

by:
Kyle Abrahams earned 500 total points
Comment Utility
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
Comment Utility
Thank you very much that solved my problem.
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
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…
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, Just open a new email message.  In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

762 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now