不允许代表我的客户在office365

时间:2017-08-04 07:10:57

标签: c# email office365 exchange-server

我尝试使用我的客户从地址(info@myclient.com)向我的客户的客户发送电子邮件。 我的客户已经通过SPF将我的smtp服务器配置到他们的域。 以下是为发送电子邮件而编写的C#代码。

 MailMessage mail = new MailMessage();
 //set the addresses           
 mail.From = new MailAddress("info@mycient.com");
 mail.To.Add("krishna.menan@gmail.com");
 mail.Subject = "This is an email";
 mail.Body = "this is a sample body with html in it. <b>This is bold</b> 
<font color=#336699>This is blue</font>";
 mail.IsBodyHtml = true;
 SmtpClient smtp = new SmtpClient();
 System.Net.NetworkCredential networkCredentialRFE = new 
 System.Net.NetworkCredential("kirshna@mycomapny.com", "Password123");
  smtp.Credentials = networkCredentialRFE;
 smtp.Host = "outlook.office365.com";
 smtp.EnableSsl = true;
 smtp.Port = 587; 
 smtp.Send(mail);

以下是我得到的错误:  信箱不可用。服务器响应是:5.7.60 SMTP;客户端无权作为此发件人发送

1 个答案:

答案 0 :(得分:0)

Make sure that the taskuser you are using has the proper "send as" permissions, see "Give mailbox permissions to another user in Office 365 - Admin Help".