好的,所以我有这个程序本质上是一个公司的电子邮件客户端,它为他们构建电子邮件并发送出去。通过Microsoft Exchange Server发送电子邮件
我已经做了这一切,但要发送电子邮件时,他们得到一个Mailbox Unavailable. Accessed Denied - Invalid HELO Name
但有趣的是,我使用的网络凭据相同的用户名和从部分。
编辑:更新代码,我现在正在使用...现在得到Failure sending mail
错误。
这里是我MailConst.cs
类:
public class MailConst
{
/*
*/
public static string Username = "username";
public static string Password = "password";
public const string SmtpServer = "smtp.domain.co.uk";
public static string From = Username + "@domain.co.uk";
}
,这里是我的主类中使用这些变量:
public static void SendMail(string recipient, string subject, string body, string[] attachments)
{
SmtpClient smtpClient = new SmtpClient();
NetworkCredential basicCredential = new NetworkCredential(MailConst.Username, MailConst.Password, MailConst.SmtpServer);
MailMessage message = new MailMessage();
MailAddress fromAddress = new MailAddress(MailConst.From);
// setup up the host, increase the timeout to 5 minutes
smtpClient.Host = MailConst.SmtpServer;
smtpClient.UseDefaultCredentials = false;
smtpClient.Credentials = basicCredential;
smtpClient.Timeout = (60 * 5 * 1000);
message.From = fromAddress;
message.Subject = subject + " - " + DateTime.Now.Date.ToString().Split(' ')[0];
message.IsBodyHtml = true;
message.Body = body.Replace("\r\n", "<br>");
message.To.Add(recipient);
if (attachments != null)
{
foreach (string attachment in attachments)
{
message.Attachments.Add(new Attachment(attachment));
}
}
smtpClient.Send(message);
}
正如一个方面说明。该程序在使用我的凭证时,在通过我自己的服务器时工作,在将其链接到他们的服务器时不起作用。
当他们使用这个程序时,他们是否使用自己的凭据(或他们使用您的凭据)? – Halvard
另外,你见过这个问题:http://stackoverflow.com/questions/3155242/troubleshooting-mailbox-unavailable-the-server-response-was-access-denied-i – Halvard
我一直在使用2硬编码证书集:他们和我的......他们使用他们的。 是的我已经看过那个答案,并没有使用,因为我在问题中说,用户名和From是完全一样的,请参阅'MailConst.cs' –