UseDefaultCredentials

0 votes
asked Jun 26, 2012 by TomS (120 points)
edited Jun 26, 2012

I'm in a situation where I have a standard System.Net.Mail.Smtpclient instance set up (thanks to some older code) on one hand, and a Rebex MailMessage instance (loaded from eml - the reason why I used Rebex) on the other.

Way I see it, the easiest way to send that message is to create a Rebex.Net.Smtp client instance and set it up using properties from the System.Net.Mail client. However, I cannot find a way to set the UseDefaultCredentials property... how can I do that?

I found a property of the same name in the Rebex documentation, but it seems to apply only to the static Send method via SmtpConfiguration class - I am however using an instance of the client.

System.Net.Mail.SmtpClient SystemClient = Mail.GetSmtpClient(Con, null);
Rebex.Mail.MailMessage msg = new Rebex.Mail.MailMessage();
msg.Load(FileName);
Rebex.Net.Smtp client = new Smtp();
if (SystemClient.EnableSsl){
   client.Connect(SystemClient.Host, SystemClient.Port, null, SmtpSecurity.Explicit);
}
else{
   client.Connect(SystemClient.Host, SystemClient.Port);
}
if (SystemClient.UseDefaultCredentials){
   ???
}
Applies to: Rebex Secure Mail

1 Answer

0 votes
answered Jun 26, 2012 by Tomas Knopp (58,890 points)
edited Jun 26, 2012

If I understand correctly that UseDefaultCredentials enables logging to the SMTP server via windows credentials of the user, than we have support for this (Ntlm or GssApi authentication.) Using SmtpAuthentication.Auto chooses the best SmtpAuthentication method possible:

if (SystemClient.UseDefaultCredentials)
{
    smtp.Login(SmtpAuthentication.Auto);
}
...