Click here to Skip to main content
15,887,267 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Anyone Help Me Please.
How to send mail in c# using exchange server 2010 without NetworkCredential
Now, I'm coding in C# using SmtpClient But I don't use Email and Password in NetworkCredential

public static void SendMailTest(string toMailId, string ccMailId)
{
string SMTP_Server_var = SMTP_Server;
int SMTP_Port_var = Convert.ToInt32(SMTP_Port);
string fromMailId = SMTP_Login;
string fromMailPassword = SMTP_Password;
string mailnoreply = "no-reply@xxx.com";
MailMessage mailmsg = new MailMessage();

mailmsg.From = new MailAddress("xxx@xxx.com", SystemEmail);
string From = mailmsg.From.ToString();

mailmsg.To.Add(toMailId);
mailmsg.CC.Add(ccMailId);
mailmsg.Headers.Add("Reply-To", SystemEmail);
mailmsg.ReplyTo = new MailAddress(SystemEmail); //Set Reply To Complete
mailmsg.Subject = subject;
mailmsg.Body = body;

mailmsg.SubjectEncoding = System.Text.Encoding.Default;

SmtpClient objclient = new SmtpClient(SMTP_Server_var, SMTP_Port_var);

objclient.UseDefaultCredentials = true;
objclient.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;

objclient.Send(mailmsg);
}

In Above Code is Return Error :
Mailbox unavailable. the server response was: 5.7.1 client does not have permissions to send as this sender
When Send From C# Class, I used with Web Application
So I want to found Solution to Solve This Error

Thank You Very Much.
Posted

1 solution

XML
SmtpClient smtp = new SmtpClient();
smtp.Host = "<My smtp.Host>";
smtp.EnableSsl = false;
smtp.Credentials = CredentialCache.DefaultNetworkCredentials;
smtp.DeliveryMethod = System.Net.Mail.SmtpDeliveryMethod.Network;
smtp.Send(message);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900