C# 无法向组发送邮件电子邮件id

C# 无法向组发送邮件电子邮件id,c#,email,smtp,C#,Email,Smtp,我正在使用smtp(c#)并尝试将邮件发送到组id(官方id),但它无法发送邮件。虽然通过相同的代码,我可以将邮件发送到个人id。知道这里可能有什么问题吗。 下面是我正在使用的代码 MailMessage mail = new MailMessage(); mail.To = "group@company.com"; mail.From = "me@company.com"; mail.Subject = "Test Mail: please Ignore"; mail.Body = body;

我正在使用smtp(c#)并尝试将邮件发送到组id(官方id),但它无法发送邮件。虽然通过相同的代码,我可以将邮件发送到个人id。知道这里可能有什么问题吗。 下面是我正在使用的代码

MailMessage mail = new MailMessage();
mail.To = "group@company.com";
mail.From = "me@company.com";
mail.Subject = "Test Mail: please Ignore";
mail.Body = body;
SmtpMail.SmtpServer = "mailhub.int.company.com";
SmtpMail.Send(mail)
我的邮箱中出现以下错误:

Delivery has failed to these recipients or distribution lists:

group@company.com
Not Authorized. You are not authorized to send to this recipient or distribution list. For distribution lists please check approved senders in the corporate directory.

  _____  

Sent by Microsoft Exchange Server 2007    

Diagnostic information for administrators:

Generating server: GSPWMS005.int.company.com

group@company.com
#550 5.7.1 RESOLVER.RST.AuthRequired; authentication required ##
从这个错误中,我可以知道某些身份验证丢失了,但不确定是哪一个或如何解决它。 如果我通过outlook向该组发送邮件,则其工作正常。


您的exchange服务器需要身份验证-您需要将其编码为以您的身份登录,或以他们同意的服务帐户登录。假设您不需要身份验证?Exchange 2007默认设置通讯组不允许从匿名来源发送,这可能不是您的意图。您必须进入并将组设置为接收来自每个人的邮件:
MailMessage message = new MailMessage(from, to);

message.Body = "This is a test e-mail message sent by an application. ";
message.Subject = "Test Email using Credentials";

NetworkCredential myCreds = new NetworkCredential("username", "password", "domain");
CredentialCache myCredentialCache = new CredentialCache();        
try 
{
    myCredentialCache.Add("ContoscoMail", 35, "Basic", myCreds);
    myCredentialCache.Add("ContoscoMail", 45, "NTLM", myCreds);

    client.Credentials = myCredentialCache.GetCredential("ContosoMail", 45, "NTLM");
    client.Send(message);
    Console.WriteLine("Goodbye.");
}
catch(Exception e)
{
    Console.WriteLine("Exception is raised. ");
    Console.WriteLine("Message: {0} ",e.Message);
}